Function Details: difference

Description


Returns the difference of two or more sets as a new set.


Extended Description


The difference() method returns a new set containing elements that are in the original set but not in the specified iterable(s). It can take multiple iterables as arguments. If an element is in the original set and not in any of the specified iterables, it will be included in the result. This method does not modify the original set.


Function Signature


set.difference(*others: Iterable) -> set

Module: set

Class: set

Parameters



Parameter List


  • other: Iterable

Return


Returns a new set containing elements that are in the original set but not in the specified iterable(s).


Return Type


set

Output

Explanation

This example shows the difference between two sets in both directions.