Created
November 20, 2017 05:53
-
-
Save dongkwan-kim/30e4c4867ce2106a2ab673a5343fea20 to your computer and use it in GitHub Desktop.
Make cardinal number to ordinal number in python3
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]) | |
# source: https://stackoverflow.com/questions/9647202/ordinal-numbers-replacement |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment