fork download
  1. def shift_by_1(x, pos, n):
  2. tmp1 = x[pos]
  3. for i in range(pos, n):
  4. tmp2 = l[i + 1]
  5. l[i + 1] = tmp1
  6. tmp1 = tmp2
  7. l = [-2, -1, 0, 1, 2, 3, -100] # [-2, -1, -1, 0, 1, 2, 3]
  8. shift_by_1(l, 2, 6)
  9. print(l)
Success #stdin #stdout 0.03s 9120KB
stdin
Standard input is empty
stdout
[-2, -1, 0, 0, 1, 2, 3]