[Tutor] Can't print a string, gives me syntax error

Sander Sweers sander.sweers at gmail.com
Mon May 25 19:58:37 CEST 2009


2009/5/25 xbmuncher <xboxmuncher at gmail.com>:
> I ran this in IDLE:
>>>> t = 'hi'
>>>> print t
> SyntaxError: invalid syntax (<pyshell#3>, line 1)

What version of python are you using (I suspect version 3)?

> I've also tried this as sample.py :
> import string
> text = 'hello world'
> print text

If you are using python 3 then the print statement has been replaced
by the print function. Try:

print(text)

Greets
Sander


More information about the Tutor mailing list