Courses/Collections & Stdlib Toolbox

๐Ÿงฐ Collections & Stdlib Toolbox

Sets & Set Algebra

Unique members, fast membership, union / intersection.

Sets store **unique** items with O(1) membership checks. Use them to dedupe and to do set algebra: union (|), intersection (&), difference (-), symmetric difference (^).

a = {1, 2, 3}
b = {3, 4, 5}
print(a | b, a & b, a - b, a ^ b)
main.py
Output
Press Run to execute.
Expected output
[1, 2, 3]
True
[1, 2, 3, 4]
[2, 3]

Sign in to track your progress across lessons.