Skip to content

Commit ab9fdc6

Browse files
authored
fix syntax for adding thousands separator
1 parent 94f09af commit ab9fdc6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/cheatsheet/string-formatting.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ Adding thousands separator
8888

8989
```python
9090
>>> a = 10000000
91-
>>> print({0:,}.format(a))
92-
# 10,000,000
91+
>>> "{0:,}".format(a)
92+
# '10,000,000'
9393
```
9494

9595
Rounding
9696

9797
```python
9898
>>> a = 3.1415926
99-
>>> print("{0:.2f}".format(a))
100-
# 3.14
99+
>>> "{0:.2f}".format(a)
100+
# '3.14'
101101
```
102102

103103
Showing as Percentage

0 commit comments

Comments
 (0)