+ 1
Why it is saying self not defined...why it won't print value of name
class Wolf: def __init__(self, name, color): self.name = name self.color = color def bark(self): print("Grr...") class Dog(Wolf): def bark(self): print("Woof") husky = Dog("Max", "grey") husky.bark() print(self.name)
2 Answers
+ 2
In your last line, your code doesn't know what self is, because it is not inside a class. Instead, try to print husky.name
+ 1
Ok tq