0
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
trincot
  • 317,000
  • 35
  • 244
  • 286

1 Answers1

0

The .format method expects the {} kind of interpolation syntax, not the older % syntax. So do:

       print ("{} x £ {}".format(thisdenom, denom))

Or use f string syntax:

       print (f"{thisdenom} x £ {denom}")
trincot
  • 317,000
  • 35
  • 244
  • 286