# Format Integer With Comma Using Python Printf

**URL:** <https://discuss.streamlit.io/t/format-integer-with-comma-using-python-printf/2344>\
**Category:** Using Streamlit\
**Created:** [March 30, 2020, 4:43pm UTC](https://discuss.streamlit.io/t/format-integer-with-comma-using-python-printf/2344 "2020-03-30T16:43:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/sean/32/1399_2.png) [@Sean](https://discuss.streamlit.io/u/Sean)\
**Post date:** [March 30, 2020, 4:43pm UTC](https://discuss.streamlit.io/t/format-integer-with-comma-using-python-printf/2344/1 "2020-03-30T16:43:59Z")

</div>

I have built a slider that has integer values between, say, 0 and 2,000,000. I would like to display the numbers with thousands-commas-separator. The documentation states:

```auto
format (str or None) – A printf-style format string controlling how the interface should display numbers. This does not impact the return value. Valid formatters: %d %e %f %g %i

```

But it isn’t clear how I could accomplish this with the `format` argument.

Usually, in Python, this can be accomplished with:

```auto
x = 1000000
print(f"{x:,}")
# 1,000,000

```

---

<div class="post-metadata">

**Author:** ![Jonathan\_Rhone](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/jonathan_rhone/32/1545_2.png) [@Jonathan\_Rhone](https://discuss.streamlit.io/u/Jonathan_Rhone)\
**Post date:** [April 1, 2020, 2:46am UTC](https://discuss.streamlit.io/t/format-integer-with-comma-using-python-printf/2344/2 "2020-04-01T02:46:02Z")

</div>

Hey @Sean,

Welcome to the forum 👋

We use the [sprintf-js](https://github.com/alexei/sprintf.js#readme) library to handle string formatting in the client.

I don’t believe this is currently possible, after looking at their documentation.

Feel free to file a feature request for this functionality!

However I’m not sure we’ll get to it right away, given the diversity of formats that could possibly be requested.

Also, we’ve started development on plugins, so this is something you should be able to build yourself in the near future!

---

<div class="post-metadata">

**Author:** ![Sean](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/sean/32/1399_2.png) [@Sean](https://discuss.streamlit.io/u/Sean)\
**Post date:** [April 3, 2020, 12:47am UTC](https://discuss.streamlit.io/t/format-integer-with-comma-using-python-printf/2344/3 "2020-04-03T00:47:34Z")

</div>

Thanks @Jonathan_Rhone. Is there a way to convert the integer as a custom string?

---

<div class="post-metadata">

**Author:** ![arraydude](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/arraydude/32/498_2.png) [@arraydude](https://discuss.streamlit.io/u/arraydude)\
**Post date:** [April 3, 2020, 7:49pm UTC](https://discuss.streamlit.io/t/format-integer-with-comma-using-python-printf/2344/4 "2020-04-03T19:49:31Z")

</div>

Hey @Sean,

That’s not possible today but I created a new [feature request](https://github.com/streamlit/streamlit/issues/1301) for you.

---

<div class="post-metadata">

**Author:** ![AZ84](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/az84/32/6735_2.png) [@AZ84](https://discuss.streamlit.io/u/AZ84)\
**Post date:** [May 27, 2021, 7:20am UTC](https://discuss.streamlit.io/t/format-integer-with-comma-using-python-printf/2344/5 "2021-05-27T07:20:32Z")

</div>

It’s a year old post and I was wondering if anyone was able to come up with a solution !?  
Thanks,

---

<div class="post-metadata">

**Author:** ![zhou\_sean](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/zhou_sean/32/11826_2.png) [@zhou\_sean](https://discuss.streamlit.io/u/zhou_sean)\
**Post date:** [January 2, 2022, 11:16pm UTC](https://discuss.streamlit.io/t/format-integer-with-comma-using-python-printf/2344/6 "2022-01-02T23:16:54Z")

</div>

I am also waiting for this function.

---

<div class="post-metadata">

**Author:** ![bloukanov](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/bloukanov/32/46803_2.png) [@bloukanov](https://discuss.streamlit.io/u/bloukanov)\
**Post date:** [January 18, 2022, 9:35pm UTC](https://discuss.streamlit.io/t/format-integer-with-comma-using-python-printf/2344/7 "2022-01-18T21:35:01Z")

</div>

Same here!
