[Tutor] re: Leap year problem

Don Arnold Don Arnold" <darnold02@sprynet.com
Tue Jan 14 21:53:02 2003


----- Original Message -----
From: "ahimsa" <ahimsa@onetel.net.uk>
To: "Don Arnold" <darnold02@sprynet.com>
Cc: <tutor@python.org>
Sent: Tuesday, January 14, 2003 3:51 PM
Subject: Re: [Tutor] re: Leap year problem


> Hi Don
> I know this is a bit belated, but dammit ... that work thing :-)
>

I definitely know how that goes. Not a problem!

<snip> of the leap year code itself. Thanks goes out to Michael Janssen for
giving a more rigorous explanation of the code than mine..

> > year = int(raw_input('year: '))
> > while year != -1:
> >     print 'isLeapYear :', isLeapYear(year)
> >     print 'isLeapYear2:', isLeapYear2(year)
> >     print ''
> >     year = int(raw_input('year: '))
> >
<snip output>
> >
>
> This is a bit confusing, so I want to pick this apart too if you can
> bear with me while I plod through this: These are my understandings line
> by line, please steer me right if I'm going off track here.
> line 1 => gets user input
> line 2 => runs program on the proviso that a number >= 0 is entered at
> input
> thereafter you are testing both ways of writing the program given
> specific years using '1' for yes it is a leap year and '0' for not.
> The last line with '-1' stops the program because it violates the while
> condition?
>

Yes, entering -1 for the year invalidates the loop's condition and it
terminates.

> It did - thank you :)

Your welcome.

>
> Andrew
>
> --
> ahimsa <ahimsa@onetel.net.uk>
>

Don