Very Easy question concerning input
Fredrik Lundh
fredrik at pythonware.com
Mon Jan 17 05:41:01 EST 2000
> can someone tell me how to use a variable from a previous line and get a
> variable from the currentline using raw_input, for example
>
> I am trying to make a simple program that ask the user his name then says
> "welcome (name) would you like to do something"
>
> I tried this...but it doesn't work right...
>
> name=raw_input ("What is your name?")
> choice1=raw_input "welcome, %s, would you like to do something?" % name
>
> doing this displays a %s instead of the persons name
really? I get a syntax error:
File "sample", line 2
choice1=raw_input "welcome, %s, would you like to do something?" % name
^
SyntaxError: invalid syntax
> can you tell me how to fix this?
just add parentheses:
choice1 = raw_input("welcome, %s, would you like to do something?" % name)
</F>
More information about the Python-list
mailing list