Is it possible to produce the following somehow?
name = raw_input("Enter name: ")
age = raw_input("Hello %s, please enter your age") %name
I know I can substitute a + to concatenate the strings, but I was curious if this would work somehow.
Is it possible to produce the following somehow?
name = raw_input("Enter name: ")
age = raw_input("Hello %s, please enter your age") %name
I know I can substitute a + to concatenate the strings, but I was curious if this would work somehow.
Just put the variable inside parentheses
age = raw_input("Hello %s, please enter your age" % name)
You should do it using the newer python string formatting:
age = raw_input("Hello {0}, please enter your age".format(name))
It gives you many more formatting options. Do read.