Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- russian = 'абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'
- again = True
- class LengthError(Exception):
- def __init__(self):
- print('At least 2 characters are required')
- class NumError(Exception):
- def __init__(Self):
- print('Numbers are not allowed')
- while again == True:
- try:
- text = input('Your text goes here: ')
- text = text.replace(" ","")
- if len(text)<2:
- raise LengthError
- else:
- for item in text:
- if item not in string.ascii_lowercase and item not in russian:
- raise NumError
- except:
- print('Try again')
- pass
- else:
- if text == text[::-1]:
- print('This is a palindrome')
- else:
- print("This isn't a palindrome")
- while True:
- ask = input("Do you want to try again? y/n: ")
- if ask == 'y':
- break
- elif ask == 'n':
- again = False
- break
- else:
- print('Invalid response')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement