+ 2
Why is the result of the code in the description showing me "Woof!" in a different line and then "Dogs always None" ??
class Animal: def __init__(self, name, color): self.name = name self.color = color class Cat(Animal): def purr(self): print("Purr...") class Dog(Animal): def bark(self): print("Woof!") fido = Dog("Fido", "brown") print("Dogs always",fido.bark())
4 odpowiedzi
+ 12
No, it doesn't return it to the calling line. It prints Woof in the bark method without returning a value.
+ 11
Your bark method doesn't return a value, that's the reason why None is printed.
+ 2
but it returns the value "Woof!" first.
+ 1
okay thnx