Boring exact change solution

This commit is contained in:
Joe S 2021-01-23 18:47:51 -05:00
parent cb99c6af49
commit d27d5025fb
1 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,24 @@
try:
user_cents = int(input('Cents: '))
except ValueError:
print('Cannot cannot parse input.')
exit()
change = []
while user_cents > 100:
user_cents -= 100
change.append('Dollar')
while user_cents > 25:
user_cents -= 25
change.append('Quarter')
while user_cents > 10:
user_cents -= 10
change.append("Dime")
while user_cents > 5:
user_cents -= 5
change.append("Nickel")
for _i in range(user_cents):
change.append("Penny")
print(change)