Boring exact change solution
This commit is contained in:
parent
cb99c6af49
commit
d27d5025fb
|
@ -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)
|
Loading…
Reference in New Issue