A python quick method to get your numbers postfixed with two letters in order to get an ordinal string version of a number. This is helpful when you want to display number in a more human way. The method also handles special case of number being or ending with 11, 12 and 13.

Pyton Ordinal

ORDINAL_LIST = ["th","st","nd","rd","th","th","th","th","th","th"]

def ordinal(value):
  if (value % 100 in (11,12,13)):
    suffix = "th"
    suffix = ORDINAL_LIST[ value % 10 ]
  return "%s%s" % (value, suffix)


>>> ordinal(113)
>>> ordinal(11)
>>> ordinal(1)
>>> ordinal(191)
>>> ordinal(400)