Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Invalid syntax with print "Hello World"

2,774 views
Skip to first unread message

Henrik Bechmann

unread,
Mar 12, 2009, 2:57:11 AM3/12/09
to
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?

Thanks,

- Henrik

Gary Herron

unread,
Mar 12, 2009, 3:24:05 AM3/12/09
to pytho...@python.org

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
>

Daniel Fetchinson

unread,
Mar 12, 2009, 3:24:06 AM3/12/09
to pytho...@python.org

Are you using python 3.0? In this case please see:

http://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function

HTH,
Daniel

--
Psss, psss, put it down! - http://www.cafepress.com/putitdown

John Machin

unread,
Mar 12, 2009, 3:25:53 AM3/12/09
to
On Mar 12, 5:57 pm, Henrik Bechmann <hbechm...@gmail.com> wrote:
> obviously total mewbiew:
>
> My first program in Python Windows

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.

HTH,
John

steven.oldner

unread,
Mar 12, 2009, 7:21:46 AM3/12/09
to
> > - Henrik- Hide quoted text -
>
> - Show quoted text -

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
challenge.

Steve Oldner

Dotan Cohen

unread,
Mar 12, 2009, 7:45:55 AM3/12/09
to steven.oldner, pytho...@python.org
> 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
> challenge.
>

I do not think that is the best way to go about learning Python. Why
learn an arguably depreciating version when the new version is
available. I agree that there are not many tutorial written for Python
3 however there are enough to get going: most of the Python 2
tutorials are redundant. Sticking to Python 3 tutorials will give him
a higher signal-to-noise ratio in the tutorials that he finds.

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü

Paul Boddie

unread,
Mar 12, 2009, 9:08:46 AM3/12/09
to
On 12 Mar, 12:45, Dotan Cohen <dotanco...@gmail.com> wrote:
>

[starting with 2.6]

> I do not think that is the best way to go about learning Python. Why
> learn an arguably depreciating version when the new version is
> available. I agree that there are not many tutorial written for Python
> 3 however there are enough to get going: most of the Python 2
> tutorials are redundant. Sticking to Python 3 tutorials will give him
> a higher signal-to-noise ratio in the tutorials that he finds.

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

Henrik Bechmann

unread,
Mar 12, 2009, 9:09:14 AM3/12/09
to
On Mar 12, 7:45 am, Dotan Cohen <dotanco...@gmail.com> wrote:
> > 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
> > challenge.
>
> I do not think that is the best way to go about learning Python. Why
> learn an arguably depreciating version when the new version is
> available. I agree that there are not many tutorial written for Python
> 3 however there are enough to get going: most of the Python 2
> tutorials are redundant. Sticking to Python 3 tutorials will give him
> a higher signal-to-noise ratio in the tutorials that he finds.
>
> --
> Dotan Cohen
>
> http://what-is-what.comhttp://gibberish.co.il

>
> א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
> ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
> А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
> а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
> ä-ö-ü-ß-Ä-Ö-Ü

Thanks everyone!

Now that I know what the issue is (2 vs 3), I'll be able to resolve
those kinds of issues in the future.

Thanks again!

- Henrik

Luis Zarrabeitia

unread,
Mar 12, 2009, 1:34:59 PM3/12/09
to pytho...@python.org
On Thursday 12 March 2009 07:45:55 am Dotan Cohen wrote:
> I do not think that is the best way to go about learning Python. Why
> learn an arguably depreciating version when the new version is
> available.

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.

> I agree that there are not many tutorial written for Python
> 3 however there are enough to get going: most of the Python 2
> tutorials are redundant. Sticking to Python 3 tutorials will give him
> a higher signal-to-noise ratio in the tutorials that he finds.

That is true. We need python tutorials aimed at python2.6 :D

--
Luis Zarrabeitia (aka Kyrie)
Fac. de Matemática y Computación, UH.
http://profesores.matcom.uh.cu/~kyrie

andygon...@gmail.com

unread,
Apr 13, 2013, 12:03:17 PM4/13/13
to
Thank you.I got the same error.And your suggestion is so useful.

johanne...@gmail.com

unread,
Nov 14, 2013, 10:05:08 AM11/14/13
to
thanx

unknown

unread,
Nov 14, 2013, 11:41:23 AM11/14/13
to
which version of python?
if V3.X then you need print ('Hello World')
as print has changed from a statement to a function.

bob gailer

unread,
Nov 14, 2013, 4:22:19 PM11/14/13
to johanne...@gmail.com, pytho...@python.org
On 11/14/2013 10:05 AM, johanne...@gmail.com wrote:
> Am Donnerstag, 12. M�rz 2009 07:57:11 UTC+1 schrieb Henrik Bechmann:
>> obviously total mewbiew:
>>
>> My first program in Python Windows
>>
>> print "Hello World"
I assume you are running Python 3 in which case you need
> print("Hello World")

--
Bob Gailer
919-636-4239
Chapel Hill NC

0 new messages