def change():
paid = Decimal(input("Amount Paid: £"))
change = Decimal(10) - Decimal(paid)
#10-4.75
print ("Change due: £", Decimal(change))
print ("Hand the customer: ")
denoms = map(Decimal, ('5.00', '2.00', '1.00', '0.50', '0.20', '0.10', '0.05', '0.02', '0.01'))
remain = change
for denom in denoms:
thisdenom, remain = divmod(remain, denom)
if thisdenom > 0:
print ("%d x £ %s" .format(thisdenom, str(denom)))
change()
no change in output -
Amount Paid: £4.50
Change due: £ 5.50
Hand the customer:
%d x £ %s
%d x £ %s