Nov-12-2020, 08:07 AM
I am pasting my code below:-
class A: def __init__(self,i=100): self.i=100 class B(A): def __init__(self,j=0): self.j=j b=B() print(b.j) print(b.i)I have 2 class A and B . B is inheriting class A so according to the concept of inheritance base class acquires property of parent class so Instance variable i must be accessible to class B . But it is giving me an error that :
Error:Traceback (most recent call last):
File "D:/PYTHON/jljl.py", line 16, in <module>
print(b.i)
AttributeError: 'B' object has no attribute 'i'
Why this is giving error.