How do I add two sets?

Compute the union of the sets using:

c = a | b

Sets are unordered sequences of unique values. a | b, or a.union(b), is the union of the two sets — i.e., a new set with all values found in either set. This is a class of operations called “set operations”, which Python set types are equipped with.

Leave a Comment