School

in #italast month

class School:
def init(self):
self.student ={}
self.history = []

def student_exists(self, name):
    for grade in self.student:
      return name in self.student[grade]
    return False # dopo aver controllato tutte le liste, se non l´ho trovato non esite
        
def add_student(self, name, grade):
    if self.student_exists(name):
        self.history.append(False)
        return # alternativa di break, ma salta fuori dalla funzione
    if grade not in self.student:
        self.student[grade] = []
    self.student[grade].append(name)
    self.history.append(True)
       
def roster(self):
    ls_st=[]
    for grade in sorted(self.student.keys()):
        ls_st += sorted(self.student[grade])
    return ls_st 

def grade(self, grade_number):
    if grade_number in self.student:
        return sorted(self.student[grade_number])
    else:
        return []
        
def added(self):
    return self.history