Python Set union() method

Python Set union() method

The set.union() method in Python returns a set that contains all items from the original set and all items from the specified sets.

Syntax

Parameter

set1- This parameter represents the first set to search for equal items

set2- This argument signifies the other set to search for equal items.

One can compare as many sets as needed, only need to separate the sets with a comma.  

Return

This method returns a new set with distinct elements from all the sets and writing the common elements between both the sets only once.

Example 1

Output

Example 2

Output

Example 3

Output