Is it possible to improve the efficiency of this code ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.")

9th Jan 2022, 12:13 PM
Fredkishala
Fredkishala - avatar
2 Answers
+ 6
#try this word = input().lower() print("Palindrome" if word == word[::-1] else "Not a palindrome")
9th Jan 2022, 12:39 PM
Simba
Simba - avatar
+ 1
Simba it works at perfection thanks.
9th Jan 2022, 12:42 PM
Fredkishala
Fredkishala - avatar