Make 2 sets out of sequences: Intersection, Union, Difference : Set « Data Structure « Python






Make 2 sets out of sequences: Intersection, Union, Difference

 

X = set('spam') 
Y = set(['h', 'a', 'm'])                      # Make 2 sets out of sequences
print X, Y 
print X & Y                                   # Intersection
print X | Y                                   # Union
print X - Y                                   # Difference

   
  








Related examples in the same category

1.set intersectionset intersection
2.Use set to key vowelsUse set to key vowels