How do I add two sets?

All you have to do to combine them is

c = a | b

Sets are unordered sequences of unique values. a | b or a.union(b) is the union of the two sets (a new set with all values found in either set). This is a class of operation called a “set operation”, which Python setprovide convenient tools for.

Leave a Comment