-
Notifications
You must be signed in to change notification settings - Fork 466
/
check_Palindrome.py
30 lines (24 loc) · 994 Bytes
/
check_Palindrome.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def isPalindrome(str,rev_str):
x = str == rev_str
return x
while True:
try:
choice = int(input("Press the number corresponding to the option to select it\n0.\tExit\n1.\tCheck for Palindrome\n"))
if choice == 1:
string = input("Enter the string you want to check: ")
low_str = string.lower()
rev_str = low_str[-1::-1]
result = isPalindrome(low_str,rev_str)
if result == True:
print(f"\n{string} is a palindrome!")
elif result == False:
print(f"\n{string} is not a palindrome as it spells {rev_str} when reversed.")
else:
print("invalid input")
elif choice == 0:
print("\n####################\tThank you for using my program\t####################")
break
else:
print("\nInvalid input")
except:
print("\nEnter an integer value corresponding to your choice!")