+ 1
why the answer is 1 ?
class Animal: i=0 def __init__(self,name): self.name = name Animal.i+=1 class Cat(Animal): i=Animal.i def __init__(self,name): self.name = name Cat.i +=1 sylvester = Cat('Sylvester') print(Cat.i)
1 Answer
+ 2
Because
Animal.i = 0
Cat.i = Animal.i
Then look what happens when a cat is made