$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #186

Which fix removes the bug?

class Node:
    def __eq__(self, other):
        return self.id == other.id
  1. Define __hash__ as well
  2. Compare with is too
  3. Subclass from object
  4. Add a __repr__ method
Defining __eq__ sets __hash__ to None, so instances can no longer go in a set or dict.
Play Problem Solving ▸