Question: python 3.xx Recursion A palindrome is a word or phrase that reads the same forwards or backwards (e.g. dad, mom, deed). Write a recrusive function,

python 3.xx

Recursion

A palindrome is a word or phrase that reads the same forwards or backwards (e.g. "dad", "mom", "deed"). Write a recrusive function, isPalindrome that accepts a string and returns whether the string is a palindrome. A string is a palindrome if:

*it is an empty string or consists of a single letter, or

*if the first and last characters are the same, and the rest of the string forms a palindrome

Your function should ignore spaces and only compare letters.

'

this is what I have , works with different words or phrases like "racecar", "!", but not with "never odd or even"

def isPalindrome(string):

if len(string) <= 1: return True elif string[0] != string[len(string) - 1]: return False return isPalindrome(string[1:len(string) - 1])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!