[Tutor] Now I have a variable-passing problem!

alan.gauld@bt.com alan.gauld@bt.com
Sun, 14 Oct 2001 18:24:45 +0100

> you recursively call get_number you aren't storing the value 
> like 'result = get_number()' is needed.  

Or just use rawNum...

You could also change the logic of the range check to 
simplify a little more and by raising a ValueError 
keep all the error handling in one place..

def get_number():
     rawNum=raw_input("Enter a number between 0 and 10,000: ")
         num_int = int(rawNum)
         if 0 <  num_int < 10000:
             return rawNum
         else: raise ValueError
     except ValueError:
         print "Sorry please try again."
         return get_number()  

Since get_number only ever returns a valid number there's 
no need to have an intermediate 'result'. 

Just nit-picking...

Alan g.