simple question about raw_input

Michael P. Reilly arcege at shore.net
Tue Jan 18 20:20:27 EST 2000


TechSpood <ScrewMe at mypad.com> wrote:
: Ok I am about as new a you can get to programming and I have a question
: which should be very simple.

: I am trying to make a simple program which ask the user for his/her name
: then says
: "hello (name) what would you like to do something"
: after it displays this it is supposed to take the users input and store it
: in a variable... all in 2 lines (which I think is possible)

: I tried this but it doesn't quite work right...can you tell me what I am
: doing wrong?

: name=raw_input ("What is your name?")
: choice1=raw_input "hello, %s, would you like to do something?" % name

The raw_input function needs the parentheses aroudn the rest of the
line:
  choice1= raw_input ("hello, %s, would you like to do something?" % name)

The parentheses are necessary so the language to do things like:
  
  >>> round(10.0 / 4.0) * 5.0
  15.0
  >>> round(10.0 / 4.0 * 5.0)
  13.0
  >>>

Where the parentheses start and end tells what to pass to the round()
function.

  -Arcege




More information about the Python-list mailing list