Skip to content

Commit

Permalink
Merge pull request #44 from Cyber-Mukherjee/main
Browse files Browse the repository at this point in the history
Create check_Palindrome.py
  • Loading branch information
Ayu-hack authored Oct 3, 2024
2 parents 3b63598 + b923e19 commit 4738a3a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions check_Palindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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!")

0 comments on commit 4738a3a

Please sign in to comment.