ReferenceSet methods
set.union()
Everything in either set.
Signature
a.union(b) or a | bParameters
| Name | Means |
|---|---|
b | another set or iterable |
Returns
A new set.
Example
Python
a = {1, 2}
b = {2, 3}
print(sorted(a | b))
print(sorted(a.union([4])))Output
[1, 2, 3] [1, 2, 4]