Python set symmetric_difference Operation

Python set symmetric_difference Operation

Instructor-svgAl-Mamun Sarkar
Mar 24 , 2020

Python set symmetric_difference Operation. The following code shows how to find symmetric_difference on set in python. This is the solution of the HackerRank Set .symmetric_difference() Operation Python Sets problem.

Code:

n = int(input())
english = set( map( int, input().split() ) )

p = int(input())
franch = set( map( int, input().split() ) )
new_set = english.symmetric_difference(franch)
print( len(new_set) )

 

Test Input:

9
1 2 3 4 5 6 7 8 9
9
10 1 2 3 11 21 55 6 8

Test Output:

8
  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram