Advertisement
IMustRemainUnknown

Palindrome Python

Dec 14th, 2023
670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | Source Code | 0 0
  1. exit_word = "imUnknown"
  2.  
  3. while True:
  4.     my_text = input("Word: ")
  5.     splitted = my_text.split(' ')
  6.  
  7.     my_text = "".join(splitted)
  8.  
  9.     left = ""
  10.     right = ""
  11.  
  12.     for i in range(int(len(my_text)/2)):
  13.         left = my_text[i].lower()
  14.         right = my_text[-(i+1)].lower()
  15.  
  16.         if left != right:
  17.             print(my_text, "is not palindrome")
  18.             break
  19.     else:
  20.         print(my_text, "is a palindrome word")
  21.  
  22.     if my_text == exit_word:
  23.         break
  24.     else:
  25.         print("------------------------------------------------")
  26.  
  27.  
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement