[Tutor] IF statements

Alan Gauld alan.gauld at btinternet.com
Mon Oct 6 10:31:04 CEST 2008


"WM" <WFERGUSON1 at SOCAL.RR.COM> wrote

> to IF.  The code below was not written by me.  It is a copy/paste 
> job from the tutor.  I do not have any idea what is going wrong.

> >>> x = int(raw_input("Please enter an integer: "))
> Please enter an integer: 42
> >>> if x < 0:
> ...      x = 0
> ...      print 'Negative changed to zero'
> ... elif x == 0:
> ...      print 'Zero'
> ... elif x == 1:
> ...      print 'Single'
> ... else:
> ...      print 'More'
> ...
> More
> 12
> SyntaxError: invalid syntax

It looks as if you maybe cut more than you intended?
Also I'm not sure about the ... prompts. I don't have 2.6 yet
so maybe its an enhancement to IDLE but notmally IDLE
doesn't print ... prompts. Did you cut n paste them too?
If so that would confuse IDLE.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list