[Tutor] 'Hello world'

Andre Engels andreengels at gmail.com
Fri Jan 1 11:31:17 CET 2010


On Fri, Jan 1, 2010 at 11:17 AM, Eldon L Mello Jr <eldonjr at hotmail.com> wrote:
> Hi there,
>
> I must say I'm quite embarrassed about my issue. Ok, I'm a 101% newbie in
> programming and all but I honestly didn't expect I would have problems in my
> very first step which was just to print 'hello world'.
>
> Despite some idiot little thing I might be overlooking I wonder if Python
> 3.1.1 was properly installed in my machine. I got a AMD Turion X2 64
> processor and Win7 Pro-64 so I suppose the Python 3.1.1 AMD64 version I got
> was the best pick right?
>
> here it comes:
>
> Python 3.1.1 (r311:74483, Aug 17 2009, 16:45:59) [MSC v.1500 64 bit (AMD64)]
> on win32
> Type "copyright", "credits" or "license()" for more information.
>>>>
>>>> print 'hello world!'
>
> SyntaxError: invalid syntax (<pyshell#0>, line 1)
>>>>
>>>> print "hello world!"
>
> SyntaxError: invalid syntax (<pyshell#1>, line 1)
>>>>
>
> Thanks a million,

This is something that has changed between Python 2 and Python 3. In
Python 2 what you tried is perfectly valid, but in Python 3 print has
become a function, so you have to write:

print("hello world!")

or

print('hello world!')

Happy New Year!



-- 
André Engels, andreengels at gmail.com


More information about the Tutor mailing list