Boring exact change solution
This commit is contained in:
24
3/3.13 Exact Change/exact_change/main.py
Normal file
24
3/3.13 Exact Change/exact_change/main.py
Normal 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)
|
||||
Reference in New Issue
Block a user