fork(1) download
  1. def nao_comuns(a,b):
  2. a_b = a+b # juntar as duas para percorrer todos os elementos
  3. return [ele for ele in a_b if ele not in a or ele not in b]
  4.  
  5. a = range(10) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  6. b = range(0,20,2) # [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
  7. print nao_comuns(a,b) # [1, 3, 5, 7, 9, 10, 12, 14, 16, 18]
Success #stdin #stdout 0.01s 23288KB
stdin
Standard input is empty
stdout
[1, 3, 5, 7, 9, 10, 12, 14, 16, 18]