class NoSuchStudentException(Exception): """Žiak nie je v zozname.""" DEFAULT_STUDENTS = [ "Alena", "Boris", "Cyril", "Daniel", "Eva", "František", "Gitka", "Helena", "Ivana", "Jozef", "Karol", "Ladislav",] PLANTS = {"G": "Tráva", "C": "Ďatelina", "R": "Reďkovky", "V": "Fialky"} class Garden(): def __init__(self, diagram, students=None): self.diagram = diagram self.rows = diagram.splitlines() names = DEFAULT_STUDENTS if students is None else students self.students = sorted(names) def plants(self, student): if not isinstance(student,str): raise TypeError("Student name has to be string") if student not in self.students: raise NoSuchStudentException(f"Student {student} does not exist") start = self.students.index(student) * 2 return [PLANTS[code] for row in self.rows for code in row[start:start + 2]]