Question: Write a function palindrome ( s ) that takes a string s and returns True if s is a palindrome. Otherwise, it returns False. A
Write a function palindromes that takes a string s and returns True if s is a palindrome. Otherwise, it returns False. A palindrome is a word that reads the same in both direction. For example, "bob" is a palindrome because the reverse of "bob" is still "bob". But "cat" is not a palindrome because the reverse of "cat" is "tac". Hint: you can create a string that is the reverse of s and then simply compare the two. Another way is to compare the character from the left and right and keep moving until you get to the center. For even number of character word, the center would be empty. For odd, the center would be one letter.
Write a program that asks the user for a word and prints whether the word is or is not a palindrome.
Sample run:
Enter word: bob bob is a palindrome. Enter word: cat cat is NOT a palindrome. Enter word: car car is NOT a palindrome. Enter word: racecar racecar is a palindrome. Enter word: is a palindrome. Enter word:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
