fork download
  1. def pairs(a,b):
  2. tmp=[]
  3. for aa in a:
  4. if (aa in b) and (aa not in tmp):
  5. tmp+=[aa]
  6. # если нужны пары
  7. print(str(tmp))
  8. res=[]
  9. for i in range(len(tmp)):
  10. x=tmp[i]
  11. res+=[(x,x)]
  12. return res
  13.  
  14. x = ['a1', 'b1', 'c1', 'd1']
  15. y = ['a1', 'b1', 'c1', 'd1', 'g1']
  16. print(str(pairs(x,y)))
Success #stdin #stdout 0s 27704KB
stdin
Standard input is empty
stdout
['a1', 'b1', 'c1', 'd1']
[('a1', 'a1'), ('b1', 'b1'), ('c1', 'c1'), ('d1', 'd1')]