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?
Solution
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: https://docs.python.org/2.3/whatsnew/section-slices.html
stra = input("Enter a string: ")
def goodone(stra):
if(str(stra) == str(stra)[::-1]):
print("It is palindromic.")
else:
print("The entered string was not a palindrome.")
goodone(stra)