Advertisement
kevinbocky

palindrome.py

May 8th, 2020
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #Ask the user for a string and print out whether this string is a palindrome or not.
  2. #(A palindrome is a string that reads the same forwards and backwards.)
  3.  
  4. prompt1 = input("Pls enter a string \n")
  5. if prompt1.isalpha():
  6. if prompt1 == prompt1[::-1]:
  7. print(f"{prompt1} is a palindrome \n ")
  8. else:
  9. print(f"{prompt1} is not a palindrome \n ")
  10. else:
  11. print("Invalid entry \n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement