Help: low level user input
Peter Otten
__peter__ at web.de
Sun Oct 26 14:30:23 EST 2003
Kyle E wrote:
> Ok, I have a little tiny problem, a beginner problem, that I am
> overlooking. I am writing a Information Gathering Program, that takes user
> input from scripted questions and prints them in a handy list in the end.
> As of now, when one of my questions is asked, the only possible way to
> enter text is to
> type ( "John" ) minus the parenthesis. You do need the qoutation marks
> though. I just want to be able to type ( John ) without the unneeded
> quotation marks. I know someone has the answer, sorry for the
> inexperienced question, but it's ticking me off.
Use raw_input() instead of input() to get the string as typed by the user.
input() evaluates the user input what is definitely not what you want in
your little program, e. g:
>>> Peter = "John"
>>> input()
Peter
'John'
or most likely:
>>> input("First name ")
First name John
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<string>", line 0, in ?
NameError: name 'John' is not defined
>>>
HTH,
Peter
More information about the Python-list
mailing list