fork download
  1. X = [-1, -2, -3, -4, -5, 1, 2, 3]
  2. R = []
  3.  
  4. for i in X:
  5. if i < 0:
  6. R.append(i)
  7. X.pop(X.index(i))
  8. print(R)
  9. print(X)
  10.  
Success #stdin #stdout 0.02s 9048KB
stdin
Standard input is empty
stdout
[-1, -3, -5]
[-2, -4, 1, 2, 3]