Invalid syntax with print "Hello World"

H

Henrik Bechmann

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
 
G

Gary Herron

Henrik said:
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
 
J

John Machin

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
 
S

steven.oldner

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










- 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
 
P

Paul Boddie

[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
 
L

Luis Zarrabeitia

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
 
Joined
Apr 9, 2010
Messages
1
Reaction score
0
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,
 
A

andygong.happy

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

Thank you.I got the same error.And your suggestion is so useful.
 
J

johannes.gunz97

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

thanx
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top