a = [1,2,3,4,0]
def looping_thing():
append_flag = True
for i in a:
if i == 0:
append_flag = False
if append_flag:
a.append(i)
print(i)
looping_thing()
So in this code i am trying to move the item to back of the list so that i can deal with them only after i encounter value "0" in the list. So is this way of doing is correct in python?
Edit : So seems like i was not that clear. What i am doing here is....from the list i first want to deal with value 0 and execute some block of code..then move onto other value of the list and execute the same block of code. So i am just so to execute block of code "0" has the priority. Here the assumption is that i cannot sort the list and there will always be a "0" value. I hope this make sense.