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