-1

Trying to run such simple program on Windows (it works pretty good on my Mac OSX), and here is the program and error message, when cursor stops on print a, there is an alert saying end of statement expected. Do I need to do anything special for Python on Windows?

if __name__ == "__main__":
    a=[1,2,3]
    print a

Error:

D:\python3.4.0\python.exe C:/Users/mayfv/PycharmProjects/HelloWorld/HelloWorld.py
  File "C:/Users/aaa/PycharmProjects/HelloWorld/HelloWorld.py", line 4
    print a
          ^
SyntaxError: invalid syntax

thanks in advance, Lin

Lin Ma
  • 9,739
  • 32
  • 105
  • 175
  • 1
    Also sometimes the indentation do gets messed up when its a copy paste, happens with me many times, there is nothing wrong with the code, works well with python 2.7 and with python 3.X you need to write as print(a) – Brij Raj Singh - MSFT Nov 17 '15 at 05:04
  • @BrijRajSingh, tried it works when adding (). Thanks. – Lin Ma Nov 17 '15 at 05:05
  • Take a look at [2to3 - Automated Python 2 to 3 code translation](https://docs.python.org/2/library/2to3.html) – PM 2Ring Nov 17 '15 at 05:38

1 Answers1

5

In python 3.4 you need to use print(a) In python 2.7 its print a

Tony Roczz
  • 2,366
  • 6
  • 32
  • 59