Just starting out with OOP in Python, using a set of tutorials by ‘Tech with Tim’
Created a couple of classes for a student database – here is the relevant code.
class Student:
def __init__(self, name, age, grade):
self.name = name
self.age = age
self.grade = grade
def get_grade(self):
return self.grade
And
def get_avarage_grade(self):
value = 0
for student in self.students:
value += student.get_grade()
return value / len(self.students) # here
I think the issue is within the 2nd function.
Any ideas as to why I get the ZeroDivisionError and how can I fix it?
Thanks in advance.
Source: Python Questions