Which fix removes the bug?
class Node:
def __eq__(self, other):
return self.id == other.id
- Define __hash__ as well
- Compare with
istoo - Subclass from object
- Add a __repr__ method
Defining __eq__ sets __hash__ to None, so instances can no longer go in a set or dict.
Play Problem Solving ▸