DEV Community


Python Format Specifier for Thousands Separator

clavinjune profile image Clavin June Originally published at on ・1 min read

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

Discussion (0)

Editor guide