Home >>Python Set Methods >Python Set difference() Method
Python set difference() method is used to return a set that contains the difference between two sets.
Syntax:set.difference(set)
Parameter | Description |
---|---|
set | This is a required parameter. It defines the set to check for differences in. |
x = {"Abhi", "Jerry", "Mickey"}
y = {"Wings", "Alpha", "Jerry"}
z = x.difference(y)
print(z)
y = {"Wings", "Alpha", "Jerry"}
z = y.difference(x)
print(z)