educative.io

Wrong solution using default values for teams School class initialization (the same is in Team class)

Hi! Can someone help figure this out, I’ve solved the challenge, but was using this was of initialization:
class School:
def _ _ init _ _(self, name, teams = []):
self.teams = teams
self.name = name
and not this one:
class School:
def _ _ init _ _(self, name):
self.teams = []
self.name = name
which is the suggested solution for it to work correctly, but when I’m using the default value there like in a first example, it gives an error in the results, and I don’t understand what’s in play here for that difference:

Thanks! :slight_smile:


Type your question above this line.

Course: https://www.educative.io/collection/10370001/6201068373409792
Lesson: https://www.educative.io/collection/page/10370001/6201068373409792/6128617224404992

@Dmitry_Polovinkin Your solution seems to be working fine on my end. PFA a screenshot of the code and the output. It is suggested to reset the code and try again with the same initialization as yours.

Thanks

hm, that’s interesting, because that difference was the only one in my code… still good to know that those 2 ways of initialization are the same, was the main thing I wanted to know :slight_smile: thanks!

1 Like