164k views
6 votes
Write a Python statement that displays the value referenced by the number variable formatted as1,234,567.5

User SnigJi
by
6.5k points

1 Answer

2 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 Bwight
by
6.4k points