This method returns a union of two set, meaning it returns all the items from both the set excepted duplicate items. The original set remains unchanged.
Variable = A.union(B)
This method takes single argument.
- Set A is being taken with some random variables.
- Set B is being taken with some random variables.
- union() method is being applied on set A with set B.
- Value is printed in C variable.
- The union of both the sets is printed.
- How to print all the values of set? How to print all the values of sets in a single variable?
To print all the items of sets all at once we will use union() method.