0

I'm on Windows and I'm using PyScripter. For some reason everything results in a syntax error, even code that very obviously does not have a syntax error. For example,

print 6

gets a syntax error, as does,

a = 6
print a

list = (1, 2, 7, 3)
print list

print 3 + 3

or any other code I can think of that involves printing. Did I download Python wrong, am I setting it up wrong, or what?

2
  • 6
    which version of python? print is a function in 3.x. Try using print(6)
    – karthikr
    Commented Jul 10, 2013 at 21:50
  • Try print(a) instead. Print is a function in 3.x, which may be the problem. Commented Jul 10, 2013 at 21:52

3 Answers 3

4

Are you using Python 3? The print function in Python three must use parentheses:

a = 6
print(a)
1

I think you installed python 3.x on your machine but you are writing python 2.x syntax in it. Try to install python 2.x or use python 3.x syntax while writing.

1

**You haven't placed brackets in some parts of your code. Which is why Python is screaming at you. Change

 a = 6
print a

list = 1, 2, 7, 3
print list

to

 a = 6
print(a)

list = 1, 2, 7, 3
print(list)

Another thing if you're using Python3-x, Python is gonna scream at you. But on Python2-x you needn't put the brackets. From what I understood from the question, you're using Python-3X. Which is why its sending you a syntax error. And I'm pretty sure its nothing because of the Python installation. **

3
  • 1
    This doesn't add anything new to existing answers. Commented Feb 16, 2021 at 4:35
  • 1
    The community encourages adding explanations alongisde code, rather than purely code-based answers (see here).
    – costaparas
    Commented Feb 16, 2021 at 5:26
  • Ok sorry about that. Won't make the same mistakes again! I hope my edits are better.
    – user15024711
    Commented Feb 17, 2021 at 7:10