I'm following the Udacity intro to CompSci, and I don't know why my answer isn't quite correct:
Define a procedure, stamps, which takes as its input a positive integer in pence and returns the number of 5p, 2p and 1p stamps (p is pence) required to make up that value. The return value should be a tuple of three numbers (that is, your return statement should be followed by the number of 5p, the number of 2p, and the nuber of 1p stamps).
Your answer should use as few total stamps as possible by first using as many 5p stamps as possible, then 2 pence stamps and finally 1p stamps as needed to make up the total.
def stamps(targetvalue): currentvalue = 0 fives = 0 twos = 0 ones = 0 while True: if targetvalue == currentvalue: return fives, twos, ones if targetvalue - currentvalue >= 5: fives = fives + 1 currentvalue = currentvalue + 5 if targetvalue - currentvalue < 5: if targetvalue - currentvalue >= 2: twos = twos + 1 currentvalue = currentvalue + 2 if targetvalue - currentvalue == 1: ones = ones + 1 currentvalue = currentvalue + 1 else: return fives, twos, ones