idle 3 hello world


5 posts
by JackT » Thu Jul 19, 2012 7:27 pm
hello i have just got my raspberry pi but when i launch idle 3 it does not let me run hello world
here is the code

( in idle 3 )

print "helloworld"
it gives the message invalid syntax

but when i put it in idle it works why is this

thanks for your time

jackt :D :D :D :D :D :D :D :D :) :) :) :lol: :lol: :lol: :? :? :? :? :? :? :? :?
Posts: 1
Joined: Thu Jul 19, 2012 7:20 pm
by hunternet93 » Thu Jul 19, 2012 8:19 pm
If you're using Python 3, then try:
Code: Select all
 print("Hello World")

A few things have changed between Python 2 and Python 3, the print statement is one of them.
Posts: 324
Joined: Mon Dec 12, 2011 4:34 pm
by jpswaim92 » Wed Feb 20, 2013 12:24 am
in IDLE 3, you would have to put

print('hello world')

The parentheses show all that you want to print, including variables. The quotation marks indicate text, not variables. Make sure that you don't double the quotation marks, write it like an apostrophe.
Posts: 1
Joined: Wed Feb 20, 2013 12:20 am
by croston » Wed Feb 20, 2013 7:20 am
jpswaim92 wrote:Make sure that you don't double the quotation marks, write it like an apostrophe.

It doesn't matter if you use single quotes or double quotes. The important thing is to be consistent and not mix the two.
User avatar
Posts: 456
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
by Snailface » Wed Feb 20, 2013 7:56 am
You can actually mix ' and "

Code: Select all
print("Hello 'quoted' world")
print('Hello "quoted" world')


are both fine, you just run into trouble when you try to do this:

Code: Select all
print("Hello" 'quoted' world") #no!
print('Hello' "quoted" world') #no!!
# to fix that, just use and escape sequence (backslash) in front of the second " or '
print("Hello\" 'quoted' world")
print('Hello\' "quoted" world')
Posts: 17
Joined: Sun Feb 10, 2013 8:32 pm