[Tutor] Help on “IF” Statements

emo sofia emo_sofia@yahoo.com
Mon, 31 Jul 2000 17:53:37 -0700 (PDT)


Please to help me to use “IF” Statement.
I want to study how to program, but I don’t know to
use any language and I decide to study Python, it’s
pretty language, not hard but very powerful.  These
days I’m reading Python Tutorial, I understand it but
I can’t use “IF” statement.  My platform is Win2000
and I use Release 1.6.
Here is the example from the tutorial:
>>> x = int(raw_input("Please enter a number: "))
>>> if x < 0:
...      x = 0
...      print 'Negative changed to zero'
... elif x == 0:
...      print 'Zero'
... elif x == 1:
...      print 'Single'
... else:
...      print 'More'
...

I’ve done several attempts:

1.  to type it: but the result is err
	>>> x = int(raw_input("Please enter a number: "))
Please enter a number: 
Traceback (innermost last):
  File "<pyshell#2>", line 1, in ?
    x = int(raw_input("Please enter a number: "))
ValueError: invalid literal for int():

2.  to copy it (and then to delete the points from the
front):
>>> if x < 0:
      x = 0
      print 'Negative changed to zero'
 elif x == 0:
      print 'Zero'
 elif x == 1:
      print 'Single'
 else:
      print 'More'
      
Please enter a number: 7
>>>
(no error but I can’t see any print result.)
Please to explain me about “IF”, I know what it mean
and I have used it several times in Excel.
A lot of thanks
Best wishes,
Emo


__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/