Write a Python program to print number with commas as thousands separators (from right side)


This program demonstrates the use of string formatting to add commas to large numbers. The format method is used to format each number with commas separating the thousands place, and the resulting formatted string is printed to the console using the print statement.

Source Code

print("{:,}".format(2550000))
print("{:,}".format(255000))
print("{:,}".format(25500))
print("{:,}".format(2550))
print("{:,}".format(255))
print("{:,}".format(25))
print("{:,}".format(2))

Output

2,550,000
255,000
25,500
2,550
255
25
2

Example Programs