Answer to Question #298048 in Python for sruthi

Question #298048

1000 : 8

500 : 1

100 : 0

50 : 1

20 : 2

5 : 0

1 : 3


how to remove spaces before and after :

denominatio problem


1
Expert's answer
2022-02-17T07:39:24-0500
nominals = (1000, 500, 100, 50, 20, 5, 1)
amount = int(input('amount = '))
output = {}
for n in nominals:
   output[n] = amount // n
   amount %= n
for k, v in output.items():
   print(k, v, sep=':')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS