I have a simple loop that manipulates a list.
My code below simply looks for nr 1 and any 0's that are present.
All the 0's are put in a new list and the index containing 1 is changed to 0.
From the zerolist I then randomly change a 0 to 1.
I need to alter my code below a little so it does this:
Finds element/nr 1 then look for where 0 elements are and move my nr/element 1 to next available 0 .
Simply put: I need to move my nr to the next available 0.
If nr 1 is last in list [2,0,0,2,1
] then the first index containing the 0 should be changed to 1 [2,1
The list will always consist of 5 elements just like in the example below.
List will maximum contain one nr 1.
examplelist = [0,2,1,0,0]
zerolist = 
for i, j in enumerate(examplelist):
if j == 0:
elif j == 1:
Any help would be appreciated !