[Tutor] Question re: hangman.py

Hugo Arts hugo.yoshi at gmail.com
Fri Nov 13 14:36:57 CET 2009

On Fri, Nov 13, 2009 at 2:17 PM, biboy mendz <bibsmendez at gmail.com> wrote:
> http://inventwithpython.com
> chapter 8: hangman.py
> expression is: print(letter, end=' ')
> it explained:
> end keyword argument in print() call makes the print() function put a space
> character at the end of the string instead of a newline.
> however when run it gives error: SyntaxError: invalid syntax.
> What gives? This is the first time i saw such expression inside print
> function. Is this version-specific of python? I'm running version 2.5.4.

Yes, the print function is a new feature of python 3. The equivalent
statement in python 2.5 is probably something like this:

print letter, ' ',

The print function is a statement in python before 3.0. It takes a
comma-separated list of things to print. The trailing comma prevents
python from appending a newline.


More information about the Tutor mailing list