Loading section...
What Can Be in a Set?
Not everything can be an element of a set. Set elements must be hashable, which generally means they must be immutable (unchangeable after creation). This requirement exists because sets use hashing to organize elements internally. If an element could change after being added, the set would not be able to find it anymore because its hash value would be different. Notice that the coordinate set shows only four points even though we specified five. The point (0, 0) was specified twice but only appears once because sets eliminate duplicates. Tuples are hashable (as long as their contents are hashable), making them ideal for storing coordinate pairs, database keys, or any immutable combination of values. Common Mistakes to Avoid Even experienced Python programmers sometimes make mistakes when