Python program to Check for String Palindrome

str = input("Insert a string: ")
len_str = len(str)
for i in range(len_str//2):
 if str[i] != str[-1-i]:
  print("This is NOT a palindrome!")
  quit()
print("This is a PALINDROME!")

 

 

Output:

Insert a string: Python Palindrom
This is NOT a palindrome!

 

Insert a string: sys
This is a PALINDROME!

 

Subscribe For Daily Updates

100+ Python Pattern Examplespython pattern examples - star patterns, number patterns