What's Wrong With Such A Simple Code?

Joined
Aug 15, 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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top