Question: python 3 please thank you Question 5a: Verifying Palindromes Recursively (3 points) 1. A word is a palindrome if it reads the same forwards as
python 3 please thank you
Question 5a: Verifying Palindromes Recursively (3 points) 1. A word is a palindrome if it reads the same forwards as it does backwards. For instance, racecar and kayak are both palindromes, whereas computer is not. Write a function that determines whether or not a given string is a palindrome. For this question, you must write your own function and test cases. Your function should be called is_palindrome and accept a single string as input, and return the boolean value True or False as output. Your function does not need to check anything with the input, you can assume that this function will only be passed entirely lowercase strings. Use the following recursive algorithm to check if a string is a palindrome: If the string is 0 or 1 items long, it is definitely a palindrome (by definition). If the string is 2 or more characters long, remove the first and last characters, check if they are equal. If they aren't, the string is not a palindrome, otherwise, check if the remainder of the string is a palindrome. In [ ]: # Write your answer in this cell def is_palindrome (s): return In [ ]: print(is_palindrome ("featherbed") == false) print(is_palindrome("boltonotlob") == True) print(is_palindrome ("racecar") == True)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
