Creating a python method and it gives error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 Answer
+ 6
try felix.showcolor()
8th Jun 2020, 12:49 PM
Slick
Slick - avatar