Hi everyone,
I am self-learning python and just came across a question why I cannot rewrite the example on the book in another way.
The example on the book is >>>>
My way to rewrite it is >>>
I am self-learning python and just came across a question why I cannot rewrite the example on the book in another way.
The example on the book is >>>>
class Cat(): def __init__(self, name): self.name=name furball=Cat('Grumpy') print('Our latest addition:', furball.name) Our latest addtion: Grumpy
My way to rewrite it is >>>
def Cat(x) if x=='furbal': Print('Grumpy') print('Our latest addition:',Cat('furball')) Grumpy Our latest addition: None