Skip to content

Instantly share code, notes, and snippets.

@kb10uy
Created June 29, 2019 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kb10uy/47b8fc287f060537af7fb7f818bc1c91 to your computer and use it in GitHub Desktop.
Save kb10uy/47b8fc287f060537af7fb7f818bc1c91 to your computer and use it in GitHub Desktop.
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