On this page
article
Decimal for Money
Avoid float errors with Decimal.
Category: decimal
Problem
Avoid float errors with Decimal.
Solution
price = Decimal('19.99') * Decimal('3')
Notes
- Adapt variable names and paths to your project
- Add error handling for production use
- See related chapters in the Learning Path