fork(1) download
  1. def xor(list1, list2):
  2. result = []
  3. union = list1 + list2
  4. for x in union:
  5. if x not in list1 or x not in list2:
  6. result += [x]
  7. return result
  8.  
  9.  
  10. import ast
  11.  
  12. a, b = [ast.literal_eval(input()) for _ in range(2)]
  13. print(xor(a, b))
Success #stdin #stdout 0.15s 10256KB
stdin
[1,2,5,7,9]
[1,2,4,8,9]
stdout
[5, 7, 4, 8]