Function Details: union

Description


Return the union of sets as a new set.


Extended Description


The union() method returns a new set containing all unique elements from the set and the specified iterable. 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 all unique elements from the set and the specified iterables.


Return Type


set

Output

Explanation

This example demonstrates the basic usage of union(). The resulting set contains all unique elements from both s1 and s2.