def ordinal(num):
    """Returns ordinal number string from int,
       e.g. 1, 2, 3 becomes 1st, 2nd, 3rd, etc. """

    SUFFIXES = {1: 'st', 2: 'nd', 3: 'rd'}

    # 10-20 don't follow the normal counting scheme.
    if 10 <= num % 100 <= 20:
        suffix = 'th'
    else:
        # the second parameter is a default.
        suffix = SUFFIXES.get(num % 10, 'th')
    return str(num) + suffix