def get_money(money):
lst_banknotes = {1000: 0,
500: 0,
200: 0,
100: 0,
50: 2,
20: 10,
10: 10}
summa = 0
res = []
for k, v in sorted(lst_banknotes.items(), key=lambda x: -x[0]):
while summa + k <= money and lst_banknotes[k] > 0:
summa += k
lst_banknotes[k] -= 1
res.append(k)
return res
print(get_money(1600))
How to set the function to display the correct banknotes? If the entire amount cannot be withdrawn the function ceases to work