Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. import string
  2.  
  3. while True:
  4.     try:
  5.         text = input('Your text goes here: ')
  6.         if len(text)<2:
  7.             raise
  8.         else:
  9.             for item in text:
  10.                 if item not in string.ascii_lowercase:
  11.                     raise
  12.     except:
  13.         print('at least 2 characters are required and only letters are allowed, try again')
  14.         continue
  15.     else:
  16.         if text == text[::-1]:
  17.  
  18.             print('This is a palindrome')
  19.         else:
  20.             print("This isn't a palindrome")
  21.     finally:
  22.         ask = input("Do you want to try again? y/n: ")
  23.         if ask == 'y':
  24.             pass
  25.         elif ask == 'n':
  26.             break
  27.         else:
  28.             print('invalid response, exiting')
  29.             break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement