I\'m wondering if there is a quick and easy way to output ordinals given a number in python.
For example, given the number 1, I\'d like to output
1
Here's a more general solution:
def ordinal(n): if 10 <= n % 100 < 20: return str(n) + 'th' else: return str(n) + {1 : 'st', 2 : 'nd', 3 : 'rd'}.get(n % 10, "th")