+ 1
Kindly help to improve this code if there is. N.B: the code is working perfectly
PALINDROME code https://code.sololearn.com/cd93Z3f71zV2/?ref=app
2 Réponses
+ 1
Although it works....remember you can string "string methods" (while taking the input too).
This is how I would do it...
edited...so the phrase outputs correctly:
p_phrase = input("Enter either a word or phrase: ").lower()
if p_phrase.replace(' ', '') == p_phrase.replace(' ', '')[::-1]:
print('\n\n' 'The phrase "{}" is a PALINDROME'.format(p_phrase))
else:
print('\n\n' 'The phrase "{}" is not a PALINDROME'.format(p_phrase))
+ 1
rodwynnejones
Thanks for the update