Using Python How Do You Write a Palindrome Tester?

Problem scenario
You want to write a Python program that tests if a string is a palindrome. You want the calling function to have five lines of code or fewer. How do you do this?

Here is a program that interactively prompts you for a string and will tell you if it is palindromic or not.

# You may want to see this documentation page:

stra = input("Enter a string: ")

def goodone(stra):
  if(str(stra) == str(stra)[::-1]):
    print("It is palindromic.")
    print("The entered string was not a palindrome.")


Leave a comment

Your email address will not be published. Required fields are marked *