Implement a Comparable mixin that adds rich comparison operators to any class with __lt__.
Constraints
Example
>>> class Person(Comparable): ... def __init__(self, age): self.age = age ... def __lt__(self, other): ... if not isinstance(other, Person): raise NotImplementedError ... return self.age < other.age >>> p1, p2 = Person(30), Person(25) >>> p1 > p2 True >>> p1 >= p2 True >>> p1 <= p2 False >>> p1 == p2 False >>> p1 != p2 True
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints