osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implement C's Switch in Python 3


On 2019-02-03 02:51, Avi Gross wrote:
> I may be missing something, but the focus seems to be only on the rightmost
> digit. You can get that with
> 
I had the same thought, but came across a problem. "11st", "12nd", "13rd"?

[snip]
> 
> Output:
> 
>>>> for day in range(1, 32):
> 	print( nthSuffix(day))
> 	
> 1st
> 2nd
> 3rd
> 4th
> 5th
> 6th
> 7th
> 8th
> 9th
> 10th
> 11st
> 12nd
> 13rd
> 14th
> 15th
> 16th
> 17th
> 18th
> 19th
> 20th
> 21st
> 22nd
> 23rd
> 24th
> 25th
> 26th
> 27th
> 28th
> 29th
> 30th
> 31st
> 
[snip]