Function Details: symmetric_difference

Description


Return the symmetric difference of two sets as a new set.


Extended Description


The symmetric_difference() method returns a new set containing elements that are in either the set or the specified iterable, but not in both. It's equivalent to the ^ operator for sets.


Function Signature



Module: set

Class: set

Parameters



Parameter List


  • other: Iterable

Return


Returns a new set containing elements in either the set or the iterable but not both.


Return Type


set

Output

Explanation

This example demonstrates the basic usage of symmetric_difference(). The resulting set contains elements that are in either s1 or s2, but not in both.