fork(1) download
  1. a=[1,2,3,2,1,4,1,5]
  2. print a
  3.  
  4. c={}
  5. for aa in a:
  6. if not aa in c: c[aa]=1
  7. else: c[aa]+=1
  8.  
  9. b=[i for i in a if c[i]>=2]
  10. print b
  11.  
Success #stdin #stdout 0.02s 9016KB
stdin
Standard input is empty
stdout
[1, 2, 3, 2, 1, 4, 1, 5]
[1, 2, 2, 1, 1]