[Answer]-Work out correct money denominations for change

1👍

Building upon this answer, I believe this is returning the desired results:

from collections import Counter

def change(amount):
    money = ()

    for coin in [200, 100, 50, 20, 10, 5, 1, 0.5]:
        num = int(amount/coin)
        money += (coin,) * num
        amount -= coin * num

    return Counter(money)

Input and output:

>>> c = change(455.50)
>>> print c
Counter({200: 2, 0.5: 1, 50: 1, 5: 1})

Edit: If you need to pass in a negative number, create a new variable inside the function by multiplying by -1 and use it inside the function instead of amount

Leave a comment