Home

Published

- 1 min read

__ne__

img of __ne__

The solution for this is noted below

ne

Solution

   class Foo:
  def __init__(self, num):
    self.num = num

  def __eq__(self, other):
    return self.num == other.num

  def __ne__(self, other): # __ne__ represents the != operator
    return self.num != other.num

Try other methods by searching on the site. That is if this doesn’t work