[Tutor] correcting an Active State Recipe for conversion to ordinal

Kent Johnson kent37 at tds.net
Thu Feb 4 19:09:57 CET 2010

On Thu, Feb 4, 2010 at 12:11 PM, Serdar Tumgoren <zstumgoren at gmail.com> wrote:

> I just noticed, however, that in the comments section of the
> ActiveState recipe that someone is getting incorrect results for
> certain numbers (11 and 12, specifically).
> But when I use the code on my own machine it still works fine. So I
> was hoping that you all could help me "crowdsource" the issue. If you
> have the time and inclination, could you look at the code and tell me
> if and where I've gone wrong? And of course, if there's a simpler way
> to perform the conversion I'd be glad to update the recipe.  I
> certainly don't want something out in the wilds of the Web that's
> incorrect, inelegant or just plain confusing.
> Here's the link to the recipe:
> http://code.activestate.com/recipes/576888/

Perhaps the code on activestate is not a correct copy of what you are
running? The conditional at line 23 extends all the way to line 35 -
the end of the function - so if value % 100/10 == 1 no more code is
executed and None is returned.


More information about the Tutor mailing list