0
Incorrectly counting parameters?
Why does it say I passed one argument when nothing is between the parentheses? class mammal: def __init__(self, legs, eyes, hasFur): print("Creating a new mammal with",legs,"legs and",eyes,"eyes.") self.legs = legs self.eyes = eyes self.hasFur = hasFur self.liveBirth = True def makeNoise(): print("Mammal makes a noise") def addEyes(num): self.eyes += num def showData(): print("legs:",self.legs) print("eyes:",self.eyes) dog = mammal(4, 2, True) human = mammal(2, 2, False) alien = mammal(3, 10, False) human.showData()
2 Answers
+ 2
define showData () as :=>
def showData( self ) :
+ 2
Each method(function of a class) must have at least 1 parameter (conventionally named "self") that refers to the class itself.
https://code.sololearn.com/cmA01N8YPBqW/?ref=app