-
-
Save kb10uy/47b8fc287f060537af7fb7f818bc1c91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("小計: ", end="") | |
price = int(input(), 10) | |
print("お預かり: ", end="") | |
given = int(input(), 10) | |
change = given - price | |
if change < 0: | |
print("不足しています") | |
exit() | |
money_names = ['10000円札', '5000円札', '1000円札', '500円玉', '100円玉', '50円玉', '10円玉', '5円玉', '1円玉'] | |
money_price = [10000, 5000, 1000, 500, 100, 50, 10, 5, 1] | |
change_list = [] | |
for p in money_price: | |
converted = change // p | |
change_list.append(converted) | |
change -= p * converted | |
for i, q in enumerate(change_list): | |
if q == 0: | |
continue | |
print('{}: {}'.format(money_names[i], q)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment