{} creates an empty dictionary. You must use set(). โ {} creates an empty dictionary. You must use set().
Sets keep their items in the order you inserted them.
Reveal answer
Sets are completely unordered collections. โ Sets are completely unordered collections.
You can access the first item in a set using my_set[0].
Reveal answer
Sets are not sequences; they do not support indexing. โ Sets are not sequences; they do not support indexing.
Sets can contain lists or dictionaries.
Reveal answer
Set elements must be hashable, meaning they cannot be mutable objects like lists or dictionaries. โ Set elements must be hashable, meaning they cannot be mutable objects like lists or dictionaries.
Challenges
Challenge 1 +15 XP
Write a function 'unique_names' that takes a list of names and returns a new list with all duplicates removed, sorted alphabetically.
python
Test 1 โ expects "['Alice', 'Bob', 'Charlie'] \n"
Need a hint? (โ25% XP)
Convert the list to a set to remove duplicates, then back to a list, and finally use sorted().
Two Devices, No Server, No Conflicts: How Local-First Apps Merge โ Apps that work offline and reconcile afterwards need a merge that no server arbitrates. Edit two devices here, predict the merged result, and find out why the answer is usually a list neither device was holding.
Union-Find Has Two Optimisations Because It Has Two Different Failures โ Union by size and path compression are usually presented as one improvement after another. They rescue unrelated cases - and each is useless against the other's. Toggle them independently here and watch which merge order defeats which.
A Structure That Is Allowed to Be Wrong, in One Direction Only โ A Bloom filter answers have I seen this before without storing anything it has seen - and sometimes says yes about a word it has never met. Hunt for one of those false positives here, then look at exactly which bits caused it.
Pick the Structure: Ten Requirements, and Nobody Tells You the Answer โ Every other page here takes one structure apart. This one starts where real work starts - with a requirement that never names the structure. Ten jobs, four candidates each, and the wrong answers are the ones people reach for by habit.