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

Jeremiah Dodds jeremiah.dodds at gmail.com
Tue May 26 11:17:40 CEST 2009


On Mon, May 25, 2009 at 6:46 PM, phpfood <phpfood at gmail.com> wrote:

> I ran this in IDLE:
> >>> t = 'hi'
> >>> print t
> SyntaxError: invalid syntax (<pyshell#3>, line 1)
>
> I've also tried this as sample.py :
> import string
> text = 'hello world'
> print text
>
>
> It gives me a syntax error on "print text" line
>
> What's going on?
>

Are you running python3? If so,  it should be:

>>> print(t)

print changed to a function in python3. If you're just starting to learn
python, it will probably be easier if you stick to the 2.X series until you
get comfortable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090526/175f0cd1/attachment.htm>


More information about the Tutor mailing list