Jun-30-2019, 08:29 AM
(This post was last modified: Jun-30-2019, 08:29 AM by Pythonhelp82.)
I have coded this example from a course textbook (it says it is a working example), When I run the code, it is coming with a Name Error, Assessment not defined.
I have played around with the code but with no luck. Can anyone please help me correct the error? (I have followed the book line by line).
I have played around with the code but with no luck. Can anyone please help me correct the error? (I have followed the book line by line).
class Course: def __init__(self,t,m): self.__CourseTitle=t self.__MaxStudents=m self.__NumberOfLessons=0 self.__CourseLesson=[] self.__CourseAssessment=Assessment def AddAssessment(self,t,m): self.__CourseAssessment=Assessment(t,m) def AddLesson(self,t,d,r): self.__NumberOfLessons=self.__NumberOfLessons+1 self.__CourseLesson.append(Lesson(t,d,r)) def OutputCourseDetails(self): print(self.__CourseTitle,"Maximum Number: ",self.__MaxStudents) for i in range(self.__NumberOfLessons): print(self.__CourseLesson[i].OutputLessonDetails()) MyCourse=Course("Computing",10) MyCourse.AddAssessment("Programming",100) MyCourse.AddLesson("Problem Solving",60,False) MyCourse.AddLesson("Programming",120,True) MyCourse.AddLesson("Theory",60,False) MyCourse.OutputCourseDetails()