Using len()

Bryan Olson fakeaddress at nowhere.org
Sat Mar 11 03:50:54 EST 2006


ctilly at gmail.com wrote:
[...]
> But I would like to change it to be something like....
> 
> while yourguess != mynum:
> 
> 	tries = tries + 1
> 	yourguess = input("Your guess? ")
> 
> 	if len(yourguess)==0:
> 		continue
[...]
> But this throws the following error and I have no idea why.  Please
> enlighten.
> 
> My error ==>  len() of unsized object

The innocent sounding function "input()" actually invokes the perilous
"eval()". Read about it at:

    http://docs.python.org/lib/built-in-funcs.html

Try "rawinput()" instead.


-- 
--Bryan



More information about the Python-list mailing list