Sets in Python
Chapter 10: Sets
4 short lessons, with 3D animations, quizzes and coding tasks.
The lessons
Making sets
A set holds each value only once, keeps no order, and answers in very quickly.
Changing a set
add puts a value in (if it isn't there already), remove takes it out and complains if it's missing, and discard takes it out quietly.
Combining sets: | & - ^
Four operators combine two sets into a new set, choosing from the left circle, the right circle, or the overlap.
Sets in practice
Compare whole sets with == and <=, find repeats by comparing len(set(x)) with len(x), and pair a seen set with a list when the order matters.