What's Wrong With Such A Simple Code?

Joined
Aug 14, 2011
Messages
1
Reaction score
0
I am totally new to python, I wrote such a simple code, as

in file ggg.py I wrote

var = raw_input("Enter something: ")
print "you entered ", var

under linux shell, I issue
python ggg.py

it complains

File "ggg.py", line 1
var = raw_input("Enter something: ")
^
SyntaxError: invalid syntax


any idea what goes wrong?
 
Joined
Jun 28, 2017
Messages
5
Reaction score
2
What version of Python are you using?
Python 2.x has the raw_input() function, but that was done away with in
Python 3.x.
In Python 3.x your code would be:

var = input("Enter something: ")
print ("you entered ", var)

Note the () in the print function.
this happens when you have Python run your program from a command line.
You are getting a version 3 Python interpreter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,263
Messages
2,571,064
Members
48,769
Latest member
Clifft

Latest Threads

Top