What is the output of the following code ?
class MyClass: def __init__(self, cost): self.cost = cost obj = MyClass(70) obj.count = 20 obj.containers = 5 print(obj.count + len(obj.__dict__))
Error
21
23
20
obj.__dict__ is namespace dictionary of the class which contains {'cost': 70, 'count': 20, 'containers': 5}.
so len(obj.__dict__) will be 3
obj.count + 3 will be 23
Comment here: