[Tutor] Re: [Tutor] Help on "IF" Statements
Richard Chamberlain
richard_chamberlain@ntlworld.com
Tue, 1 Aug 2000 07:39:08 +0100
Emo,
this works fine:
x=int(raw_input("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'
when you say delete the points from the front do you mean the ...? The ...
and >>> shouldn't be typed they are python prompts. Type it exactly as it is
above and it should work.
Richard
----- Original Message -----
From: emo sofia <emo_sofia@yahoo.com>
To: <tutor@python.org>
Sent: Tuesday, August 01, 2000 1:53 AM
Subject: [Tutor] Help on "IF" Statements
>
> 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/
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>