say_money
say_money
Return an amount of money in words. The amount is rounded to the currency’s smallest unit, half up. A whole amount has no minor part (“one dollar”), an amount under one major unit has no major part (“five cents”), and a negative amount starts with “minus”.
Parameters
amount
The amount in the currency’s major unit: dollars, not cents. Raises ValueError
for a value that isn’t a finite number, including a bool.
currency
The ISO 4217 code, in any case. One of USD, CAD, AUD, NZD, EUR, GBP,
MXN, INR, or JPY; any other code raises ValueError. JPY has no minor
unit, so the amount rounds to whole yen.
Returns
str — The amount in words, such as "fourteen dollars and fifty cents".
Raises
ValueError for an amount that isn’t a number, or a currency not listed above.
Example
Part of the speech helpers module.