[Tutor] Help - My First Program Fails

Steven D'Aprano steve at pearwood.info
Mon Sep 10 01:36:00 CEST 2012


Please, please, PLEASE do not reply to a digest without deleting the 
irrelevant text from your email! We don't need to read HUNDREDS of lines 
of text we've already seen before.

When you want to start a *new* question, ALWAYS start a fresh, blank 
email, set the "To" address to tutor at python.org, and DO NOT reply to a 
digest. Thank you.

My answer to your question appears below:


On Sun, Sep 09, 2012 at 03:56:22PM -0700, tayo rotimi wrote:
> My first exercise: print "Game Over" does not run! Where have I missed it? The error message is as follows:
> 
>  File "<stdin>", line 1
>    print "Game Over"
>                     ^
>  SyntaxError: invalid syntax 


Are you using Python 3 instead of Python 2?

One of the changes between the 2.x versions and the 3.x versions is that 
print is no longer a statement, but is now a function. That means you 
have to write it using round brackets (parentheses for Americans):

# version 2.x
print "Game Over"

# version 3.x
print("Game Over")


For simple printing, there's not much advantage either way, but for more 
advanced printing, the function form is much better.



-- 
Steven


More information about the Tutor mailing list