Skip to content

Commit e40953a

Browse files
committed
Add intword processing for thousands
Signed-off-by: Gábor Lipták <gliptak@gmail.com>
1 parent 98fafaf commit e40953a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/humanize/number.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ def intcomma(value, ndigits=None):
119119
return intcomma(new)
120120

121121

122-
powers = [10 ** x for x in (6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 100)]
122+
powers = [10 ** x for x in (3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 100)]
123123
human_powers = (
124+
N_("thousand"),
124125
N_("million"),
125126
N_("billion"),
126127
N_("trillion"),
@@ -146,6 +147,8 @@ def intword(value, format="%.1f"):
146147
```pycon
147148
>>> intword("100")
148149
'100'
150+
>>> intword("12400")
151+
'12.4 thousand'
149152
>>> intword("1000000")
150153
'1.0 million'
151154
>>> intword(1_200_000_000)

0 commit comments

Comments
 (0)