-1

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

  • 1
    Googled "python3 input": [first result](http://www.python-course.eu/python3_input.php). – juliomalegria Jan 18 '15 at 22:57
  • 1
    possible duplicate of [How can i ask for user input and use that input for this text summarizer i created?](http://stackoverflow.com/questions/21790540/how-can-i-ask-for-user-input-and-use-that-input-for-this-text-summarizer-i-creat) – Oliver W. Jan 18 '15 at 23:10
  • 1
    Welcome to StackOverflow. Please take the time to use the search functionality (top right of this page) builtin to stackoverflow to make sure [your questions hasn't been asked before](https://stackoverflow.com/help/how-to-ask). Or use a search engine, such as Google. – Oliver W. Jan 18 '15 at 23:12

2 Answers2

1
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.

Malik Brahimi
  • 16,341
  • 7
  • 39
  • 70
1

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
SrGrace
  • 326
  • 5
  • 16