[Tutor] IF statements-1

WM WFERGUSON1 at SOCAL.RR.COM
Tue Oct 7 03:48:05 CEST 2008


TO THIS ORIGINAL POST I GOT SIX REPLIES.

WM wrote:
 > > I used to do Basic and enjoyed it.  Someone said Python was a vastly
 > > better language than Visual Basic, which I considered playing with.  So
 > > I sought to give it a go but struck a sticking point very early.
 > > I am now going through the Python tutorial.  All went well until I came
 > > 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.
 > >
 > > IDLE 2.6     >>>
 >>>> >>>>
 >>>> >>>> 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
 >>>> >>>>

IS THIS THE WAY TO ANSWER?  OR SHOULD I DO INDIVIDUAL REPLIES?

JOHNSON 1
The copy above is exactly from the book, via COPY & PASTE, from IDLE26 
thru More.
I keyed in the 12 to generate the error message.

JOHNSON 2
All that was running was IDLE from the desktop and the tutor from the 
Python.Org site.
I will not do the down-load right now as I want the tutor to work with 
the program with no tinkering.

JOHNSON 3
I did not understand Nair's reply, so I didn't follow thru there.
What is "the entire digest" and how do I not include it?

LANE
I keyed in "12" & "Enter".  The rest is copy/paste.
I will key the text into Notepad then run it, as you suggest.

GAULD
Not so.  You can check on the tutor, the code stops at 'More'.
It's funny about the dots, they were in the tutor but not in IDLE, 
although the indents were the same.  Then, in the e-mil, there they 
were.  IDLE hides dots?  What do I know?

NAIR
Your post to me starts, "also I believe..."  It looks like the front end 
got truncated.


More information about the Tutor mailing list