This article shows how to implement the set built-in at the expense of a dictionary.
If there is a 50% chance something will go wrong, then 9 times out of 10 it will.