Python programming help
Page 1 of 1 [ 4 posts ]
I have decided to learn how to program this week. Currently I am enjoying it.
I have made a extremely basic program using what I learned about inputs and outputs, it is a bit crude.
Code:
person = input ('Enter your name: ')
print ('I hate the name', person)
print ('I hate the name', person)
I saved it as program.py and in the terminal I used the command python program.py. I got a strange error,
Enter your name: C
Traceback (most recent call last):
File "hello_you.py", line 1, in <module>
person = input('Enter your name: ')
File "<string>", line 1, in <module>
NameError: name 'C' is not defined
What did I do wrong? I do I fix this?
_________________
"God may not play dice with the universe, but something strange is going on with prime numbers."
-Paul Erdos
"There are two types of cryptography in this world: cryptography that will stop your kid sister from looking at your files, and cryptography that will stop major governments from reading your files."
-Bruce Schneider
Last edited by Rudin on 01 Dec 2015, 6:39 pm, edited 2 times in total.
Freedoomed wrote:
That most certainly is because you are compiling Python 3 code with Python 2.
The right way to compile it is python3 program.py.
If you want to compile it with Python 2, you should do the following:
person = raw_input ('Enter your name: ')
print 'I hate the name', person
The right way to compile it is python3 program.py.
If you want to compile it with Python 2, you should do the following:
person = raw_input ('Enter your name: ')
print 'I hate the name', person
This fixed it, thank you.
_________________
"God may not play dice with the universe, but something strange is going on with prime numbers."
-Paul Erdos
"There are two types of cryptography in this world: cryptography that will stop your kid sister from looking at your files, and cryptography that will stop major governments from reading your files."
-Bruce Schneider