Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started