Invalid syntax with print "Hello World"

Gary Herron gherron at islandtraining.com
Thu Mar 12 03:24:05 EDT 2009


Henrik Bechmann wrote:
> obviously total mewbiew:
>
> My first program in Python Windows
>
> print "Hello World"
>
> I select Run/Run Module and get an error:
>
> Syntax error, with the closing quote highlighted.
>
> Tried with single quotes as well. Same problem.
>
> Can someone explain my mistake?
>   

You are apparently using Python2 syntax in Python3.  Python3 has made 
some incompatible changes from previous version of Python2. 

  In Python2: print "Hello World"
  In Python3: print("Hello World")


Either download Python2.5 (or 2.6) to go with your tutorial, or find a 
Python3 tutorial to go with your Python3 installation.    Once you are 
familiar with either version of the language, you will find that the 
differences are not very large, but using out-of-sync tutorials and 
implementations will be the source of much frustration.

Welcome to Python.

Enjoy.

Gary Herron



> Thanks,
>
> - Henrik
> --
> http://mail.python.org/mailman/listinfo/python-list
>   




More information about the Python-list mailing list