I'm trying to increment a python list of numbers like an abacus.
list = [0,0,0,0]
units = 4
def m(list, units):
for e in range(len(list)):
if units:
list[e] = list[e] + 1
units -= 1
This code works fine in that if I run m(list, units) the list will be [1,1,1,1] -- the problem I am trying to solve is that when the units value is something like units = 2 the list will increment to [2,2,1,1] (which again is fine) the problem is when I run the m()function from an uneven list, the list will increment from list[0] to end up [3,3,1,1] rather than [2,2,2,2].
Is there a pythonic way I can have the function increment the list from the lowest value to achieve an even spread?
list.index(min(list))(FYI,listis not a good name for a list, as it shadows the built-in)?