Theorem : there is no universal set.
Proof . Let X be such a set that X = {\empty, x} , where X is every possible element in the domain. The question is: X \in X ? Most sets are not defined in this way, so we define a new set Y. Y = {A \in X; A \notin A} Y = {A \in X; A \notin A} ie Y is the set of all sets that do not belong to themselves.
Now, Y \in Y ? Well, we defined Y as all sets that do not belong to ourselves, so Y cannot exist in Y, which contradicts our assumption.
So, now suppose that Y is not in Y. Now A definitely contains Y, since Y is not in itself, but the definition of Y is such that if we define Y in Y, we contradict our own definition.
Thus, there is no collection of all sets. This is called the Russell Paradox .
So, why programmatically try to create an object that violates a result proven and tested by set theorists much smarter than me? If this was my interview, this would be my answer, and if they insisted that it was possible, I would suggest explaining what the problem area is, since conceptually Russell proved in principle that this is impossible.
If you would like for users of introductory set theory to usually have a user-friendly problem, try Barber Paradox .
Edit : Python allows you to implement an object that contains itself. See this:
class Universal(object): def __init__(self): self.contents = [] def add(self, x): self.contents.append(x) def remove(self, x): self.contents.remove(x) def __contains__(self, x): return ( x in self.contents )
However, this is not a strict set-theoretic object, since the content actually contains a link to the parent object. If you require objects to be different in accordance with the proof above, this cannot be.