Skip to content

Instantly share code, notes, and snippets.

@cristinelpopescu
Created February 28, 2021 16:10
Show Gist options
  • Save cristinelpopescu/d839e1164000484f1f56e55d3293d028 to your computer and use it in GitHub Desktop.
Save cristinelpopescu/d839e1164000484f1f56e55d3293d028 to your computer and use it in GitHub Desktop.
Ask the user for a string and print out whether this string is a palindrome or not. A palindrome is a string that reads the same forwards and backwards.
phrase=input("Please enter a phrase or word: ")
phrase=str(phrase)
reverse= phrase[::-1]
print(reverse)
if phrase == reverse:
print("This phrase or word is a palindrome")
else:
print("This phrase or word is not a palindrome")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment