Using len()
I have what I think is a very simple question. I have a Python script
that I found that I want to tweek a little bit. All I want to do is
add in a validator to make sure a value has been keyed into the imput
box.
The code currently is...
while yourguess != mynum:
tries = tries + 1
yourguess = input("Your guess? ")
if (yourguess != mynum):
#blah blah blah
# end of the if statement
# repeat until user gets it right
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
elif (yourguess != mynum):
#blah blah blah
# end of the if statement
# repeat until user gets it right
But this throws the following error and I have no idea why. Please
enlighten.
My error ==> len() of unsized object
--
http://mail.python.org/mailman/listinfo/python-list
ERROR when hitting RETURN on INPUT
How do you prevent getting the following error when you hit the RETURN
key on an empty INPUT prompt from windows?
If I am at the Interactive Window and I type in: input("blah"), I get
an input dialog. If I then hit ENTER w/o keying in a value I get the
following error. WHY
SyntaxError: unexpected EOF while parsing
--
http://mail.python.org/mailman/listinfo/python-list
Re: Using len()
That works, thanks. Can you tell me why the differences exist? -- http://mail.python.org/mailman/listinfo/python-list
