I can't figure out why my if-else statement doesn't run as expected. I've tried to create code to test for a palindromic string. My print functions show me that the reverse method works, but when I get to the comparison stage I can't get it to return True.
Here is the code:
def is_palindrome(a):
myList = []
for i in a:
myList.append(i)
print myList
new = myList.reverse()
print myList
print new
if myList == new:
return True
else:
return False
print is_palindrome("radar")
This returns False. I have also tried changing the if statement to if myList is new:
but unfortunately it still returns False.
Any insight appreciated!