hbutils.string.ordinal

Overview:

Useful utilities for ordinal words, such as 1st, 2nd, etc.

ordinal

hbutils.string.ordinal.ordinal(n: int) → str[source]
Overview:

Get ordinal suffix of one number.

Parameters:

n – The given number.

Return suffix:

Ordinal suffix for number n.

Examples::
>>> from hbutils.string import ordinal
>>> ordinal(1)
'st'
>>> ordinal(2)
'nd'
>>> ordinal(3)
'rd'
>>> ordinal(4)
'th'
>>> ordinal(11)
'th'
>>> ordinal(21)
'st'
>>> ordinal(1001)
'st'

Note

This function is intergratted from inflection package. It will be automatically installed once you use ordinal().

ordinalize

hbutils.string.ordinal.ordinalize(n: int) → str[source]
Overview:

Get full ordinal word of one number.

Parameters:

n – The given number.

Return word:

Full ordinal word for number n.

Examples::
>>> from hbutils.string import ordinalize
>>> ordinalize(1)
'1st'
>>> ordinalize(2)
'2nd'
>>> ordinalize(3)
'3rd'
>>> ordinalize(4)
'4th'
>>> ordinalize(11)
'11th'
>>> ordinalize(21)
'21st'
>>> ordinalize(1001)
'1001st'

Note

This function is intergratted from inflection package. It will be automatically installed once you use ordinalize().