So I just started trying out python yesterday and I want to code something where I can input text then the something will be added once enter is pressed
for example:
If I input: Sam Smith After pressing enter . . . I would get: Welcome Sam Smith
So I just started trying out python yesterday and I want to code something where I can input text then the something will be added once enter is pressed
for example:
If I input: Sam Smith After pressing enter . . . I would get: Welcome Sam Smith
name = input('What is your name? ')
print('Welcome ' + name)
First, the user is asked for the name which is then stored in a variable. Then, a message is printed using the stored name.
Python2.x:
>>> name = raw_input("Please enter the name..")
Please enter the name..Sam Smith
>>> name
'Sam Smith'
>>> print "Welcome " + name
Welcome Sam Smith
Python3.x:
>>> name = input("Please enter the name..")
Please enter the name..Sam Smith
>>> name
'Sam Smith'
>>> print("Welcome " + name)
Welcome Sam Smith