coins = [200, 100, 25, 10, 5, 1] # get the amount from the user and convert to cents dollars = raw_input("How much change do you need? $") change = int( float(dollars)*100 ) print "Here's your change:" # check each denomination of coin for amount in coins: # how many of this should be given? num = change/amount # give the change if num>0: print " %i x $%.2f" % (num, amount/100.0) change = change - num*amount # if there are't 0 cents left to give, we want to know. assert change==0