+ 1

Creating a python method and it gives error

Creating a python method inside a class and it gives error. Here is the code: class Cat: def __init__(self, color, legs): self.color = color self.legs = legs def showcolor(self): print(self.color) felix = Cat("ginger", 4) print(felix.color) showcolor(felix)

8th Jun 2020, 12:47 PM
NNS
NNS - avatar
1 Resposta
+ 6
try felix.showcolor()
8th Jun 2020, 12:49 PM
Slick
Slick - avatar