Code Lab BetaBUILD. RUN. DISCOVER.
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
PYTHON STRUCTURES / CHAPTER 06 / Learn / LESSON 03
Set operations:
a = {1, 2, 3}
b = {3, 4}
print(sorted(a | b)) # union
print(sorted(a & b)) # intersection
print(sorted(a - b)) # differenceWhen printing a set for humans, use sorted(...) for predictable output.
Learn: | & - with sorted on print.
AGGREGATE IDLE
›