HackerRank Python- Symmetric Difference

Given 2 sets of integers, M and N, print their symmetric difference in ascending order. The term symmetric difference indicates those values that exist in either M or N but do not exist in both.

  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. if __name__ == "__main__":
  3. M = int(input().strip())
  4. set_m = set(map(int, input().strip().split(' ')))
  5. N = int(input().strip())
  6. set_n = set(map(int, input().strip().split(' ')))
  7. for el in sorted(set_m ^ set_n):
  8. print(el)

download android app