I'm brand new and playing around with Python. I entered this code:
person = input('Enter your name: ')
print('Hello', person)
and this happens:
>>> person = input('Enter your name: ')
print('Hello', person)
Enter your name: Sarah
Traceback (most recent call last):
File "
Using input() in this context is Python 3 syntax. You're using Python 2. To do what you expect in Python 2: person = raw_input( "Enter your name: " )
and also... to print the result that you want to see the syntax would be the following: print 'Hello, ', person or the "+" sign instead of a comma...
The + sign will print exactly what you have. The comma will print what you have and put a space in between.
Join our real-time social learning platform and learn together with your friends!