Symptom
Trying to deduplicate a list of expenses using set() raises TypeError: unhashable type: 'Expense'.
expenses = [e1, e2, e1] # e1 appears twice
unique = set(expenses) # TypeError: unhashable type: 'Expense'
What you know
The Expense class has an __eq__ method that compares by id. Two expenses with the same id are considered equal. But putting them in a set fails.
Hints
Python
Python ready
Test Output
▶
Click "Run Tests" to execute your code