Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = [1, 2, 3, 1, 2, 1, 2, 3]
- idx = []
- for i, (num1, num2) in enumerate(zip(x, x[1:])):
- if num2 < num1:
- idx.append(i+1)
- for i in reversed(idx):
- x.insert(i, 0) # or, x[i:i] = [0], which would be overkill in this case
Add Comment
Please, Sign In to add comment