Definition:
This method is used to return items that are left behind after the intersection of two sets. This method returns the item into the third variable.
Syntax
Variable = A.symmetric_difference(B).
This method takes an argument.
Working:
Code:
- Set A is being taken with some random values
- Set B is being taken with some random values
- symmetric_difference() method is being applied on set A with set B.
- Output is printed into C variable
Output
- Output is elements that are left after the intersection of two sets.
Interview Questions
- What is the difference between difference() method and symmetric_difference() method?
The difference() method returns an item that is only present in the first set and not the second, whereas the symmetric_difference method returns an item that is not present in both sets.
Quick Links: