Help with small program

Paul Watson pwatson at redlinepy.com
Mon Dec 25 00:19:35 EST 2006


Better alternative.

cointype = (100, 10, 5, 1, 0.5)

def coins(fin):
	needed = {}
	for c in cointypes:
		v, r = divmod(fin, c)
		if v > 0:
			needed[c] = v
			fin = r
	return needed

if __name__ == '__main__':
	print coins(51)
	print coins(127)
	print coins[12.5)



More information about the Python-list mailing list