I am writing a function to check if a word is a palindrome
def palidrome(b):
word = ''.join(reversed(b))
if b == word:
return True
return False
def main():
so = input("Please enter a matching word")
come = palidrome(so)
print(come)
main()
Whatever I put, e.g., 'mom,' 'dad' or 'racecar,' it always outputs False
but it should be True
.
According to this demo, your code is running fine - however, I noticed your input statement doesn't have a space after it. Are you typing a space before you put your word in? If so, consider the strip()
function, which will remove leading and trailing spaces - or just add a space to your input prompt!