Question: Python3 class A(object): def __init__(self, x,y): self.x = x self.y = y def foo1(self): self.x = 10 return self.x def foo2(self): self.y.x = 20 return

Python3

class A(object): def __init__(self, x,y): self.x = x self.y = y def foo1(self): self.x = 10 return self.x def foo2(self): self.y.x = 20 return self.y

class B(A): def __init__(self,x,y,z): A.__init__(self,x,y) self.z = z def foo1(self): self.x =5 return self.x def main(): b = B(1,2,3) print(b.foo1()) print(b.foo2())

main()

I want to get my value foo1 =5, foo2 =4 but it says that "AttributeError: 'int' object has no attribute 'x'"

Please fix the error.(Please not fix line 9 self.y.x = 20) part

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!