Beginner level: Why doesn't my code work?
Sun, 19 May 2013 07:56:50 -0700 Post Comments
[Oscar]
[Rafael]
As Oscar says you are invoking your script with Python 2. Python 2's input()
function evals user input as a Python expression. For example if you run a
script
print input("your input please: ")
and you type
1 + 1
the script will print
2
Likewise if you type
Rafael
the script will look up the value of a variable named Rafael. This doesn't
exist and therefore you get an exception.
But this is all a distraction -- how exactly are you invoking what you think
is Python 3.3.0? What is your operating system?
If you are using Linux or OSX open a terminal window and try to run your
script from that terminal window with
python3.3 ~/Documents/3_Tufcik.py
[Rafael]
As Oscar says you are invoking your script with Python 2. Python 2's input()
function evals user input as a Python expression. For example if you run a
script
print input("your input please: ")
and you type
1 + 1
the script will print
2
Likewise if you type
Rafael
the script will look up the value of a variable named Rafael. This doesn't
exist and therefore you get an exception.
But this is all a distraction -- how exactly are you invoking what you think
is Python 3.3.0? What is your operating system?
If you are using Linux or OSX open a terminal window and try to run your
script from that terminal window with
python3.3 ~/Documents/3_Tufcik.py
