Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [1]: L=[1,2,3,4,5,6,0,0,0,0,0,0,1,2,3,4,5,6]
- In [2]: pop=0
- In [3]: for i in L:
- ...: if i != 0:
- ...: pop += 1
- ...: elif i == 0:
- ...: L.pop(pop)
- ...:
- Out[3]: 0
- Out[3]: 0
- Out[3]: 0
- In [4]: L
- Out[4]: [1, 2, 3, 4, 5, 6, 0, 0, 0, 1, 2, 3, 4, 5, 6]
- In [5]:
Add Comment
Please, Sign In to add comment