[Tutor] correcting an Active State Recipe for conversion to ordinal
waynejwerner at gmail.com
Thu Feb 4 18:45:09 CET 2010
On Thu, Feb 4, 2010 at 11:11 AM, Serdar Tumgoren <zstumgoren at gmail.com>wrote:
> Hi folks,
> 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:
Well at first I was getting "None" for 11 and 12. The following conversion
fixed that problem:
if value % 100/10 <> 1:
if value % 100/10.0 <> 1:
But I'm still getting weird output:
for x in (1,2,3,11,4, 12,19,101):
Where 11 and 12 should be 11th and 12th.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor