Assume that S and T are assigned sets. Without using the join operator |, how can I find the union of the two sets? This, for example,
S
T
|
Assuming you also can't use s.union(t), which is equivalent to s | t, you could try
s.union(t)
s | t
>>> from itertools import chain >>> set(chain(s,t)) set([1, 2, 3, 4, 5, 6])
Or, if you want a comprehension,
>>> {i for j in (s,t) for i in j} set([1, 2, 3, 4, 5, 6])