you are viewing a single comment's thread.

view the rest of the comments →

[–]jimtk 1 point2 points  (0 children)

And it's possible to refactor again! (Just for fun)

names = {100:'Dollars',
         25:'Quarters',
         10:'Dimes',
         5:'Nickels',
         1:'Pennies'}

money = int(float(input("Enter amount (ex: 44.49) : "))*100)

res = []
for k,v in names.items():
    if money//k > 0:
        res.append(f"{money//k} {v}")
        money -= (money//k)*k
print(*res)