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

Doug Reid rnrcreid at yahoo.com
Mon May 25 19:56:15 CEST 2009



--- On Mon, 5/25/09, xbmuncher <xboxmuncher at gmail.com> wrote:


From: xbmuncher <xboxmuncher at gmail.com>
Subject: [Tutor] Can't print a string, gives me syntax error
To: "tutor at python.org" <tutor at python.org>
Date: Monday, May 25, 2009, 5:48 PM


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? 

I'm guessing, though I'm not that experienced with Python yet, you maybe using Python 3.0.  In this new version, you have to include () with print statements.  You didn't have to in 2.X versions.  So try:
 
text='Hello Wold'
print (text)
 
That's my guess, if you are using Python 2.x then I don't know:)


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090525/051079a4/attachment.htm>


More information about the Tutor mailing list