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

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -