We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4fa515a + 092eda1 commit 7739094Copy full SHA for 7739094
1 file changed
structural/mvc.py
@@ -27,13 +27,7 @@ class Price(float):
27
__str__ functionality."""
28
29
def __str__(self):
30
- first_digits_str = str(round(self, 2))
31
- try:
32
- dot_location = first_digits_str.index('.')
33
- except ValueError:
34
- return first_digits_str + '.00'
35
- else:
36
- return first_digits_str + '0' * (3 + dot_location - len(first_digits_str))
+ return "{:.2f}".format(self)
37
38
products = {
39
'milk': {'price': Price(1.50), 'quantity': 10},
0 commit comments