nlg_num

nlg_num #

The nlg_num method allows to transform a number in a string following several criterion.

ParameterTypeDefault Value
The numberint or float or Decimal
sep (the separator for the decimal)string‘.’
mile_sep (the seperator for mile)string' '
dec (the number of decimals to display)intNone (all decimals)
force_sign (whether to add ‘+’ before the number if is positive)booleanFalse
remove_trailing_zeros (whether to remove not significant 0 in the decimals)booleanTrue
nlg = NlgTools()

my_number = 10000.66028

str_num = nlg.nlg_num(my_number, dec=3, force_sign=True)

print(str_num)

# +10 000.66
# The remove_trailing_zeros parameter will remove the last decimal even though we indicated 3 decimals because it is a 0.