There is a kata in code guides, where the task is to write a function that takes an integer in the input and displays a string with a currency format. For example 123456→ "123,456".
I had a solution, but it was much uglier than this with string formatting:
def to_currency(price):
return '{:,}'.format(price)
I read the documentation, but I still don't know how it works exactly?
source
share