Python Format Specifier Thousands Separator

tech · Jan 16, 2021 · ~1 min
Photo by @volkanolmez on Unsplash
Photo by @volkanolmez on Unsplash

I hate to say this, but I forgot this one-liner syntax in my online coding test. So, I think I need to put this here.

format = lambda n: '{:,}'.format(n)
print(format(-1234567890)) # -1,234,567,890

Thank you for reading!

· · ·

Love This Content?

Any kind of supports is greatly appreciated! Kindly support me via Bitcoin, Ko-fi, Trakteer, or just continue to read another content. You can write a response via Webmention and let me know the URL via Telegraph.