On Thu, Feb 4, 2010 at 11:11 AM, Serdar Tumgoren <zstumgo...@gmail.com>wrote:
> Hi folks, > <snip> > 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/ > > Well at first I was getting "None" for 11 and 12. The following conversion fixed that problem: if value % 100/10 <> 1: to if value % 100/10.0 <> 1: But I'm still getting weird output: for x in (1,2,3,11,4, 12,19,101): print ordinal(x) Follows: 1st 2nd 3rd 11st 4th 12nd 19th 101st Where 11 and 12 should be 11th and 12th. HTH, Wayne
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor