423,198 views
43 votes
43 votes
Write a Python statement that displays the value referenced by the number variable formatted as1,234,567.5

User Jirkamat
by
2.2k points

1 Answer

17 votes
17 votes

Answer:

x = 1234567.5

print(f'{x:,}')

* there's various ways to accomplish this, but above seems to be the shortest. Requires python ≥ 3.6

User Rafael Sousa
by
2.6k points