Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment Write a recursive palindrome function to complete the following program. The palindrome function must be recursive. You may not use any while or for

image text in transcribedimage text in transcribedimage text in transcribed

Assignment Write a recursive palindrome function to complete the following program. The palindrome function must be recursive. You may not use any while or for loops or list comprehensions. You may use multiple base and multiple recursive cases to determine if the text is a palindrome. Base cases should return True or False when you determine if the text is or is not a palindrome. Recursive cases should skip spaces and punctuation or compare the remaining string when the end characters match. All comparisons in the function should be case sensitive, Anna is not a palindrome, but anna is a palindrome. The program should provide a text? prompt. After the user enters a line of text, the program should print Palindrome if the text is a palindrome and Emordnilap otherwise. NOTE you can check if a character is alphanumeric with "char isalnum if you want to check a character in a string 's" at position i is alphanumeric, you can use slil, isalnum salnumO returns a Boolean True of character is alphanumeric, else False Sample Input and Output text? Able was I, ere I saw Elba. Emo ranil ap text? able was I, ere I saw elba. Palindrome text? Able was I Emordnilap main.py 3 def palindrome(s): 4 "Returns True if the string parameter contains a palindrome, False otherwise.""" pass 6 7 9 def main) 10 """DO NOT CHANGE THIS CODE""" 11 text = input( 'text? ') 12 if palindrome(text): 13 14 else: 15 16 17 if_namemain_" 18 main) 19 print("Palindrome" print("Emordnilap") # not a palindrome

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions