Advertisement
CuocSong

remove_duplicate.py

Mar 25th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. def f7(seq):
  2.     seen = set()
  3.     seen_add = seen.add
  4.     return [x for x in seq if not (x in seen or seen_add(x))]
  5.    
  6. data = open("data.txt").read().splitlines()
  7. data2 = open("data.txt").read().splitlines()
  8. data = f7(data)
  9.  
  10. for i in xrange(len(data)-1,-1,-1):
  11.     if data[i] in data2:
  12.         data.remove(data[i])
  13.  
  14. open("result.txt","wb").write(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement