I made a function to check if string is a palindrome
It is suppose to replace anything in the string that is not an alphabet with '' but the replace() method isn't working
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
def is_palindrome(text):
word = text.lower()
for l in word:
if l not in alphabet:
word.replace(l, '')
return word == text[::-1]
print(is_palindrome('Rise to vote, sir.'))
I expect the output of True but the actual output is False