Created
October 10, 2018 23:54
-
-
Save rjzak/ac0630a32777b212fc67e705751c9eca to your computer and use it in GitHub Desktop.
Integer to ordinal. From https://stackoverflow.com/questions/9647202/ordinal-numbers-replacement/20007730#20007730
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
ordinal = lambda n: "%d%s" % (n,"tsnrhtdd"[(math.floor(n/10)%10!=1)*(n%10<4)*n%10::4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment