[Tutor] if...elif question

Chris Keelan rufmetal@home.com
Wed, 3 Oct 2001 00:01:38 -0500


On Tue, 02 Oct 2001, Danny Yoo wrote:
> Ah!  You probably meant to write it like this:
>
>     elif 60 <= percent < 70:

Yes! How did you know ;o)

> One thing that will simplify your code a lot is this: if we're on the elif
> part of an if test, we know that the first condition must be false --- and
> we can take advantage of this:

That's great advice. Thanks!

>
> ###
> if percent < 60: return 'f'
> elif percent < 70: return 'd'
> else: return 'a'
> ###
>
> Hope this helps!

Sure does.

- Chris