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 is an even shorter general solution:
def foo(n): return str(n) + {1: 'st', 2: 'nd', 3: 'rd'}.get(4 if 10 <= n % 100 < 20 else n % 10, "th")
Although the other solutions above are probably easier to understand at first glance, this works just as well while using a bit less code.