string - Testing for a Palindrome in Python -
i know there better solutions this, i'm confused why i'm getting result am.
import sys def ispalindrome(test): if len(test) == 1: return("is palindrome") else: if test[0] == test[-1]: ispalindrome(test[1:-1]) else: return("not palindrome") print(ispalindrome(sys.argv[1]))
on true palindrome, 'none'. when result not palindrome, expected value of 'not palindrome'.
change following line:
return ispalindrome(test[1:-1])
you have return value or value returned none
.
Comments
Post a Comment