Kodewick
Start learning →
Mini challenge←→0 / 100

Giving change

#088Mini challengeNumbersLists6 min

A vending machine gives change in 10s, 5s and 1s, biggest first. Write make_change(amount) to return [how many 10s, how many 5s, how many 1s]. For example 18 is [1, 1, 3]; 0 is [0, 0, 0].

Examples
make_change(18)→[1, 1, 3]
make_change(27)→[2, 1, 2]
main.py
def make_change(amount):
    tens = amount // 10
    amount = amount % 10
    # your code here: the same way, work out fives and ones
    fives = 0
    ones = 0
    return [tens, fives, ones]
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.