Reputation: 21
I just do not understand how to put the print function and input function at the same line. In python 3.4, I wrote it like this:
Hello = input("Hello adventurer, what is your name?")
print (Hello," ","-"," ",input("are you a warrior,wizard or programmer?"))
But, it came out like this....
Hello adventurer, what is your name?
jake
are you a warrior,wizard or programmer?
warrior
jake - warrior
if I want answer to be like this on the bottom line, how should I do it?:
Hello adventurer, what is your name?
Joe
Joe - are you a Warrior, Wizard or Programmer?
Wizard
Upvotes: 2
Views: 7542
Reputation: 11
i think you already found the answer, but it might be useful for someone else. To achieve your goal you need to use print() without end of the line symbol. you can do this by entering :
person = input('Enter your name: ')
print('Hello ', person, '!', sep='', end='')
input(' - are you a Warrior, Wizard or Programmer? :')
To achieve better look and fine text adjustment, you can use "sep" as well.
Upvotes: 1
Reputation: 37059
In Python 2.7, you can do something like this:
>>> person = input("Hello adventurer, what is your name?\n")
Hello adventurer, what is your name?
"Joe"
>>> interest = input("%s - are you a warrior, wizard or programmer?\n" % person)
Joe - are you a warrior, wizard or programmer?
"Wizard"
>>> print interest
Wizard
You might be able to achieve the same results with just some more modifications.
Upvotes: 0