Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Print number with commas as 1000 separators in Python

  • Last Updated : 05 Nov, 2017

In this program, we need to print output of a given integer in international place value format and put commas at the appropriate place, from the right.


 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Input : 1000000
Output : 1,000,000

Input : 1000
Output : 1,000

Using {} along with format() function is introduced in Python 2.7 and is generally used in String formatting in place of “%”.

" ".format()


Input  : print ('{0}, {1}, {2}'.format('a', 'b', 'c'))
Output : a, b, c

Input :  print ('{2}, {0}, {1}'.format('a', 'b', 'c'))
Output : c, a, b

Here, we have used the “{:,}” along with the format() function to add commas every thousand places starting from left. This is introduced in Python3 and it automatically adds a comma on writing the following syntax.

def place_value(number):
    return ("{:,}".format(number))



This article is contributed by Chinmoy Lenka. If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!