About classes in Python

I’m solving one task but i can’t.

I have to realise the next one class: i have to keep info about students and their marks.

Class has the next one methods:
add(studentName, mark) - adding name and mark
mark - integer from 0 to 5
studentName - name

goodStudents() returns the list of students with marks > 4.

Solution form

class Students:
def add(self, studentName, mark):

def goodStudents(self):

My solution:

class Students:    
    def add(self, studentName, mark):
        self.studentName = studentName
        self.mark = mark
        self.data = {}
        self.data[mark] = studentName
def goodStudents(self):
    for key in self.data:
        if key > 4:
            return self.data[key]

But checking system says thet I’m wrong. What can do to put it right?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.