class Parent: def _init_(self,x): self.x=x def count(self,x): self.x = self.x + 1 class Child(Parent): def _init_(self, y=0): Parent._init_(self,3) self.y = y def count(self): self.y +=1 obj=Child() obj.count() print(obj.x,obj.y)
I would like to see the output of print(obj.x,obj.y). However, I keep getting this error:
Traceback (most recent call last):
File “./code_with_class.py”, line 19, in
File “./code_with_class.py”, line 16, in count
AttributeError: ‘Child’ object has no attribute ‘y’
What do I need to do to correct this? How do I improve this code?