JackT
Posts: 1
Joined: Thu Jul 19, 2012 7:20 pm

idle 3 hello world

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: :? :? :? :? :? :? :? :?

hunternet93
Posts: 336
Joined: Mon Dec 12, 2011 4:34 pm

Re: idle 3 hello world

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.

jpswaim92
Posts: 1
Joined: Wed Feb 20, 2013 12:20 am

Re: idle 3 hello world

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.

User avatar
croston
Posts: 667
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: idle 3 hello world

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.

Snailface
Posts: 19
Joined: Sun Feb 10, 2013 8:32 pm

Re: idle 3 hello world

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')

Return to “Python”

Who is online

Users browsing this forum: No registered users and 15 guests