Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Set symmetric Using Python Set symmetric_difference() Method

# Set X
X = {1, 2, 3}

# Set Y
Y = {2, 3, 4}

# Set Z
Z = {2, 3, 4}

print("Symmetric difference between X & Y", X.symmetric_difference(Y))
print("Symmetric difference between Y & Z", Y.symmetric_difference(Z))
print("Symmetric difference between X & X", X.symmetric_difference(X))
Comment

How to Get the Symmetric Difference of Sets in Python

firstSet = {2, 3, 4, 5}

secondSet = {1, 3, 5, 7}

print(firstSet ^ secondSet)
# {1, 2, 4, 7}
Comment

PREVIOUS NEXT
Code Example
Python :: python maths max value capped at x 
Python :: boolean python meaning for idiots 
Python :: read csv without index 
Python :: pandas join two series on index 
Python :: rightclick in pygame 
Python :: find the determinant of a matrix in python 
Python :: python selenium type in input 
Python :: pandas print full dataframe 
Python :: deleting duplicates in list python 
Python :: how to change icon in pygame 
Python :: how to print all rows in pandas 
Python :: np.loadtext 
Python :: django validator min max value 
Python :: how to remove numbers from string in python dataframe 
Python :: find angle mbc in python 
Python :: python index of last occurrence in string 
Python :: python csv read header only 
Python :: The `.create()` method does not support writable nested fields by default. Write an explicit `.create()` method for serializer `room_api.serializers.roomSerializer`, or set `read_only=True` on nested serializer fields. 
Python :: reset a turtle python 
Python :: find python path cmd 
Python :: python colorama example 
Python :: get time in ms python 
Python :: how to draw in pygame 
Python :: python join paths 
Python :: pandas dataframe convert string to float 
Python :: pandas iterate columns 
Python :: from django.utils.translation import ugettext_lazy as _ 
Python :: python code formatter vs code 
Python :: list to excel python 
Python :: change default python version 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =