[Tutor] n.isalnum() is failing

Terry terry.kemmerer at gmail.com
Sat Jul 7 00:49:39 CEST 2007


Hi Janos,

Quote: Your logic is backward, and mine is the forward, isn't it?  ;)

The Story of My Life!

--Terry


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
> use
> > 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
> exceptions 
> >   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
> logic 
> 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 
> 
> 
> ps 
> 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?  ;) 
> 
> 
> Janos
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070706/b5eac1a2/attachment.html 


More information about the Tutor mailing list