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

symmetric_difference() Function of sets in python

# The symmetric_difference() function can be used to create a new set containing
# the symmetric differences of two sets.

mySet = {1, 2, 3, 4}
mySet2 = {3, 4, 5, 6}
mySet3 = mySet.symmetric_difference(mySet2)
print(mySet3)

# Output:
# {1, 2, 5, 6}
Comment

PREVIOUS NEXT
Code Example
Python :: tkinter responsive gui 
Python :: if condition dataframe python 
Python :: Pandas conditional collumn 
Python :: how to print all items in a list python 
Python :: pandas order dataframe by index of other dataframe 
Python :: size pandas dataframe 
Python :: convert pandas.core.indexes.numeric.int64index to list 
Python :: get UTC time for IST time python 
Python :: get return value from transaction in brownie 
Python :: how to add python interpreter in vscode 
Python :: download csv file from jupyter notebook 
Python :: Django how to get url path for a view 
Python :: how to get size of list in python 
Python :: activate venv 
Python :: Set value for particular cell in pandas DataFrame using index 
Python :: tkinter background image python 3 
Python :: python error handling 
Python :: pandas remove repeated index 
Python :: multiplication table python 
Python :: python to make video 
Python :: tkinter change button state 
Python :: remove decimal python 
Python :: animations on canvas tkinter 
Python :: python fibonacci function 
Python :: django model get field verbose name 
Python :: abs function in python 
Python :: python get numbers after decimal point 
Python :: gpt-3 tokenizer python3 
Python :: python remove one element from numpy array 
Python :: python switch columns order csv 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =