[Tutor] n.isalnum() is failing
terry.kemmerer at gmail.com
Sat Jul 7 00:49:39 CEST 2007
Quote: Your logic is backward, and mine is the forward, isn't it? ;)
The Story of My Life!
On Thu, 2007-07-05 at 07:30 +0200, János Juhász wrote:
> Hi Terry
> > "According to the Gregorian calendar, which is the civil calendar in
> > today, years evenly divisible by 4 are leap years, with the
> exception of
> > centurial years that are not evenly divisible by 400."
> > def isLeapYear(y):
> > if y % 4 == 0: return True
> As it always return True, if y%4 == 0, there is problem with the
> > if (y % 4 == 0) and not (y %100 == 0): return True
> > else: return False
> I feel that, the cleanest way to translate the definition into Boolean
> is to do it backward instead of thinking on the exceptions.
> def leap_year(year):
> if year%400 == 0: return True # We said these years are always
> leap year
> if year%100 == 0: return False # the exception handled already
> if year%4 == 0: return True # no problem with the exceptions
> return False # this it the default
> hungarians name format: family name, christian name
> hungarian date format: year/month/day
> Your logic is backward, and mine is the forward, isn't it? ;)
> Tutor maillist - Tutor at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor