DEV Community

Clavin June
Clavin June

Posted on • Originally published at clavinjune.dev on

Python Format Specifier for Thousands Separator

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
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay