Python palindrome program not working

后端 未结 7 804
后悔当初
后悔当初 2021-01-26 12:49

I\'ve written a simple program in python which checks if the sentence is palindrome. But I can\'t figure out why isn\'t it working. The results is always False. Does anyone know

7条回答
  •  [愿得一人]
    2021-01-26 13:28

    You aren't returning the result of the function.

    replace :

    if word[0] == word[-1]:
        isPalindrome(word[1:-1])
    

    with

    if word[0] == word[-1]:
        return isPalindrome(word[1:-1])
    

提交回复
热议问题