Help: low level user input

Discussion in 'Python' started by Kyle E, Oct 26, 2003.

  1. Kyle E

    Kyle E Guest

    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.

    This is my program:

    from time import sleep

    ##INTRODUCTION
    print "Personal Information Program"
    print "----------------------------"
    print
    sleep(3)
    print "Please input the requested information... "
    sleep(1)

    ##INPUT NAME
    print "ID: "
    sleep(2)
    print "What is your first name?"
    fname = input ("> ")
    sleep(1)
    print "What is your middle initial?"
    mname = input ("> ")
    sleep(1)
    print "What is your last name?"
    lname = input ("> ")
    sleep(1)

    ##INPUT ADDRESS
    print "Location: "
    sleep(2)
    print "What is your street address?"
    saddy = input ("> ")
    sleep(1)
    print "What city do you live in?"
    city = input ("> ")
    sleep(1)
    print "What state do you live in?"
    state = input ("> ")
    sleep(1)
    print "What is your zipcode?"
    zip = input ("> ")
    sleep(1)
    print "Do you have a P.O. Box?"
    poan = input ("> ")
    if poan == yes:
    print "What is your P.O. Box number?"
    pobox = input ("> ")
     
    Kyle E, Oct 26, 2003
    #1
    1. Advertising

  2. Kyle E

    Peter Otten Guest

    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
     
    Peter Otten, Oct 26, 2003
    #2
    1. Advertising

  3. Kyle E

    Kyle E Guest

    > 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.


    Peter Wrote:
    >
    > 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
    >


    Kyle Wrote:

    I forgot about using raw_input, now I can finish writing my program, Thanks
    a lot Peter
     
    Kyle E, Oct 26, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page