Advertisement Jump to content
Sign in to follow this  
golden code

Invalid syntax with print "Hello World"

This topic is 2686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?


Share this post

Link to post
Share on other sites
Like SiCrane said that is valid Python 2.x code but not valid code for Python 3, in Python 3 you'd have to do
print("hello, world!")

Assuming you installed the latest version of python I think you are using python 2.x syntax in python 3 ;)

See this link for more information: http://docs.python.o...atsnew/3.0.html

The print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement (PEP 3105). Examples:
Old: print "The answer is", 2*2
New: print("The answer is", 2*2)

Old: print x, # Trailing comma suppresses newline
New: print(x, end=" ") # Appends a space instead of a newline

Old: print # Prints a newline
New: print() # You must call the function!

Old: print >>sys.stderr, "fatal error"
New: print("fatal error", file=sys.stderr)

Old: print (x, y) # prints repr((x, y))
New: print((x, y)) # Not the same as print(x, y)!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!