Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- while True:
- try:
- text = input('Your text goes here: ')
- if len(text)<2:
- raise
- else:
- for item in text:
- if item not in string.ascii_lowercase:
- raise
- except:
- print('at least 2 characters are required and only letters are allowed, try again')
- continue
- else:
- if text == text[::-1]:
- print('This is a palindrome')
- else:
- print("This isn't a palindrome")
- finally:
- ask = input("Do you want to try again? y/n: ")
- if ask == 'y':
- pass
- elif ask == 'n':
- break
- else:
- print('invalid response, exiting')
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement