title: python program to overload ‘==’ operator to print the details of students having same marks
body: <p>Here I have to create a class student with following member attributes: roll no, name, age and total marks. Create suitable methods for reading and printing member variables also to overload ‘==’ operator to print the details of students having same marks. Here I can't find way how to overload == operator for marks. Here I have got error.</p>
  
  <pre><code>class Student():
  
  
      def __init__(self,r_no,name,age,marks):
          self.r_no = r_no
          self.name = name
          self.age = age
          self.marks = marks
  
  
      def displayStudent(self):
          print ("Roll no : ", self.r_no, "Name : ", self.name,  ", Age: ", self.age,  ", Marks: ", self.marks)
  
  
      def __str__(self):
          return "({0},{1},{3},{4})".format(self.r_no,self.name,self.age,self.marks)
  
      def __eq__(self,other):
          if(self.marks==other.marks):
              return self.marks==other.marks
  
  
  stu = []
  
  for i in range (1,3):
      print("Enter Details for Students %d" % (i))
      r_no = int(input("Enter Roll no:"))
      name = input("Enter Name:")
      age = int(input("Enter Age:"))
      marks = input("Enter Marks:")
      stu.append(Student(r_no,name,age,marks))
  
  
  
  for s in stu:
      s.displayStudent()
  </code></pre>