Dear Educative Community,
In the Class School
, we have the following code,
getTotalPlayersInSchool(self):
length = 0
for n in self.teams:
length = length + (n.getNumberOfPlayers())
return length
But here getNumberOfPlayers()
is from the class Team
. Here how can the object ‘n’ from School access getNumberOfPlayers()
without first doing something like this,
n = Team()
Please point out relevant previous lessons related to this, if this concept is mentioned there.
Thanks
Santhanakrishnan.
Type your question above this line.
Course: https://www.educative.io/collection/10370001/6201068373409792
Lesson: https://www.educative.io/collection/page/10370001/6201068373409792/5909785754992640