Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

WMBenham

macrumors newbie
Original poster
Jul 20, 2010
3
0
Hey all,

I just started learning Python and am working in IDLE. My very first tutorial suggested I try the basic "Hello, World" test and when I input
Code:
print "Hello, World"
I get an invalid syntax error. Am I missing something here?
 

MorphingDragon

macrumors 603
Mar 27, 2009
5,160
6
The World Inbetween
Hey all,

I just started learning Python and am working in IDLE. My very first tutorial suggested I try the basic "Hello, World" test and when I input
Code:
print "Hello, World"
I get an invalid syntax error. Am I missing something here?

Functions need brackets around them.

print("My life is average currently")

What python tutorial are you using? I might be able to get you/point to something better and more up-to-date (PM me)
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,423
A sea of green
The following works for me. Mac OS 10.6.3.

First, launch Terminal.app. Enter this command:
Code:
python -m idlelib.idle
A few seconds elapse, then a separate Python Shell window appears with the copyright notice, firewall message, and finally the >>> prompt. Example from an IDLE tutorial:
http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html
except mine says IDLE 2.6.1.

I then type in:
Code:
print "Hello, world"
and hit Return. It prints what I typed in.

This isn't the only way to run Python's IDLE, but it does work here.


I suggest copying the contents of the IDLE window that shows the command and resulting error message, and pasting it into a post. It's as simple as cmd-A (Select All), cmd-C (Copy) in the IDLE window, then paste it into a reply post and surround it with CODE tags.


It would be a good idea to identify exactly which OS version and Python version you're using, along with the IDLE version. Also, if you're using IDLE.app rather than the command-line I entered, or some other way of starting IDLE, that should also be identified.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.