I am a beginner in python, and I am trying to do the following exercise:
"Write a function that takes a string as a parameter and returns True if the string is a palindrome " (recursively)
Here's what I've written:
- Code: Select all
while len(pal) != len(str):
pal = str[-1] + reverse(str[:-1])
This gives me the string backwards. However, when I am trying to compare them, I keep getting errors. I have tried using == and is, but they don't seem to work. Why can't i use these boolean operators in a recursive function and how can I solve it?