You’ve tried to add an object into a set and a
TypeError: unhashable type: exception was raised. You were probably using a set becase you needed a collection of objects without duplicates. If that was the case, two ways of solving this come to mind
__hash__method for the parent class of that object as per the guidelines in the Python documentation.
Extend the inbuilt data-type
listand override it’s
An instance of this class will behave exactly like a normal list, but won’t allow duplicates to be added to it.
itemobject’s parent class needs to have it’s
__eq__method implemented for this to work.
Author Timothy Makobu