python - Can anyone tell me what's wrong with my function? -


i'm working on project , keep getting problem when code tries return "guess" variable, instead of returning value of "guess" goes line 9 converts value string reason, , returns that. when go use returned value in something, python says value "nonetype".

def ask_question(max_length, roworcol, guessnumber):     guess = raw_input("what "+roworcol+" number of "+guessnumber+" guess? ")     try:         guess = int(guess)         if guess <= max_length:             return guess         else:             print "that number big, must no larger " +str(max_length)             ask_question(max_length, roworcol, guessnumber)     except(typeerror):         print "only numbers accepted, please try again!"         ask_question(max_length, roworcol, guessnumber) 

i call function line:

first_guess_row = ask_question(4, "row", "first") 

is there i'm missing?

of course branches need return....

...         else:             print "that number big, must no larger " +str(max_length)             return ask_question(max_length, roworcol, guessnumber)     except(typeerror):         print "only numbers accepted, please try again!"         return ask_question(max_length, roworcol, guessnumber) 

before recalling function ... throwing away return value


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -