Invalid syntax with print "Hello World"

Discussion in 'Python' started by Henrik Bechmann, Mar 12, 2009.

  1. 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?


    - Henrik
    Henrik Bechmann, Mar 12, 2009
    1. Advertisements

  2. Henrik Bechmann

    Gary Herron Guest

    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.


    Gary Herron
    Gary Herron, Mar 12, 2009
    1. Advertisements

  3. obviously total mewbiew:
    Are you using python 3.0? In this case please see:

    Daniel Fetchinson, Mar 12, 2009
  4. Henrik Bechmann

    John Machin Guest

    What is that you are callind "Python Windows"? What version of Python
    are you running?

    2.X: print "Hello World"
    should work.

    3.X: print is now a function,
    print("Hello World")
    should work.

    If that gets you going: read the tutorial that belongs to the version
    of Python that you are using.
    If it doesn't, come back here with a bit more detail.

    BTW, don't indent your first line. Make sure it starts in column 1.

    John Machin, Mar 12, 2009
  5. Henrik,

    Welcome to the list. As a newbie myself, I ran into the Python3 vrs
    2.6 issue. May I suggest starting with 2.6? There is many more books
    and internet stuff you can learn with in 2.6 - and the examples will
    work. As Garry wrote, once you understand 2.6, 3.0 will not be a

    Steve Oldner
    steven.oldner, Mar 12, 2009
  6. Henrik Bechmann

    Paul Boddie Guest

    [starting with 2.6]
    So we are to conclude that Python 2 is redundant now, are we?

    I don't think it's bad advice to suggest that people learn Python 2 if
    they want to get stuff done, and since people keep saying how Python 3
    is really the same language, let us entertain that assertion and
    encourage people to take advantage of its predecessor: the thing which
    actually powers the overwhelming majority of Python-powered systems
    today and for the foreseeable future.

    Paul Boddie, Mar 12, 2009
  7. Because it is not only the language that matters, you also need the libraries
    to accomplish real-world tasks. As a language, python2 is an impressive one,
    and python3 is a great improvement over python2, but python3 still lacks some
    of the libraries and framewoks that makes programming in python so extremely
    delightful (yes, I like python :D).

    I don't consider python2 deprecated (can't be deprecated yet!), and as a
    teacher and/or student, I'd recomment to teach/learn python2.5-2.6, keeping
    an eye on all those features that are new in python3... and backporting
    everything that is possible to backport.
    That is true. We need python tutorials aimed at python2.6 :D
    Luis Zarrabeitia, Mar 12, 2009
  8. Henrik Bechmann


    Apr 9, 2010
    Likes Received:
    2.6 vs 3.0

    Hello, I'm a total newbie aswel.

    I am wondering why python 2.6 or even 2.5.4 is still educated and not 3.0?
    I have read that 3.0 is complete redesign of the language, so I asume it would be helpful to educate in that version.

    Is there anyone who can explain this?

    Best regards,
    timmylangeveld, Apr 9, 2010
  9. Thank you.I got the same error.And your suggestion is so useful.
    andygong.happy, Apr 13, 2013
  10. Am Donnerstag, 12. März 2009 07:57:11 UTC+1 schrieb Henrik Bechmann:
    johannes.gunz97, Nov 14, 2013
  11. Henrik Bechmann

    bob gailer Guest

    I assume you are running Python 3 in which case you need
    bob gailer, Nov 14, 2013
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.