fork download
  1. def remove_items(lst, items):
  2. items = set(items) # unnecessary in your case
  3. pos = 0
  4. for x in lst:
  5. if x not in items:
  6. lst[pos] = x
  7. pos += 1
  8. del lst[pos:]
  9.  
  10. a=[2,6,79,10]
  11. b=[6,7,2,0,8,5]
  12.  
  13. common = set(a).intersection(b)
  14. remove_items(a, common)
  15. remove_items(b, common)
  16. print(a)
  17. print(b)
  18.  
  19. assert a == [79,10]
  20. assert b == [7,0,8,5]
  21.  
Success #stdin #stdout 0.01s 5740KB
stdin
Standard input is empty
stdout
[79, 10]
[7, 0, 8, 5]