Skip to content

Instantly share code, notes, and snippets.

@frantizek
Created January 28, 2022 23:51
Show Gist options
  • Save frantizek/1c8fd8897965b1d112f1ebca114c2988 to your computer and use it in GitHub Desktop.
Save frantizek/1c8fd8897965b1d112f1ebca114c2988 to your computer and use it in GitHub Desktop.
import re
def palindrome_test(phrase):
cleanString = re.sub('\W+', '', phrase.lower())
return cleanString == cleanString[::-1]
while True:
user_entry = input("Enter string to test for palindrome or 'exit' : ")
if user_entry.lower() == 'exit':
break
else:
print("Palindrome test:", palindrome_test(user_entry))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment