Cyttorak

Untitled

Jun 6th, 2021 (edited)
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. x = [1, 2, 3, 1, 2, 1, 2, 3]
  2. idx = []
  3. for i, (num1, num2) in enumerate(zip(x, x[1:])):
  4.     if num2 < num1:
  5.         idx.append(i+1)
  6. for i in reversed(idx):
  7.     x.insert(i, 0)      # or, x[i:i] = [0], which would be overkill in this case
Add Comment
Please, Sign In to add comment