logo CodeStepByStep logo

print_palindrome

Language/Type: Python if/else input string

Write a function named print_palindrome that prompts the user to enter one or more words and prints whether the entered string is a palindrome (i.e., reads the same forwards as it does backwards, like "abba" or "racecar"). For an added challenge, make the code case-insensitive, so that words like "Abba" and "Madam" will be considered palindromes. Here is the resulting output for two calls:

Type one or more words: racecar
racecar is a palindrome!
Type one or more words: hello
hello is not a palindrome.
Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.