+ 1
Is it possible to improve the efficiency of this code ?
word= input("Please enter a palindrome word: ") #This convert the string to lower case low = word.lower() #This reverses the string text pal = low[::-1] print("\n") if word == pal: print("The word you have entered is a palindrome.") else: print("The word you have entered is not a palindrome.")
2 Answers
+ 6
#try this
word = input().lower()
print("Palindrome" if word == word[::-1] else "Not a palindrome")
+ 1
Simba it works at perfection thanks.