fork download
  1. def intersecao(conjuntoA, conjuntoB):
  2. inter = []
  3. for x in conjuntoA:
  4. if x in conjuntoB:
  5. inter.append(x)
  6. return inter
  7.  
  8. a = [2,4,6,7,10]
  9. b = [3,4,6,8,10,11]
  10.  
  11. print(intersecao(a,b))
Success #stdin #stdout 0.02s 28384KB
stdin
Standard input is empty
stdout
[4, 6, 10]