Python Math: Print number with commas as thousands separators
26. Thousands Separator Formatter
Write a Python program to display numbers separated by commas as thousands.
Sample Solution:
Python Code:
print("{:,}".format(1000000))
print("{:,}".format(10000))
Sample Output:
1,000,000 10,000
Pictorial Presentation:
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to format a given number with commas as thousands separators using string formatting.
- Write a Python function that accepts a large integer and returns it as a string with commas separating the thousands.
- Write a Python script to convert multiple numbers to strings with thousands separators and print them in a column.
- Write a Python program to take user input for a number, format it with commas, and then display the formatted number.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program for nth Catalan Number.
Next: Write a Python program to calculate distance between two points using latitude and longitude.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.