Which fix removes the bug?
def greet(self, name):
return "Hi " + name
class Greeter:
greet = greet
- Define
greetinside the class body - Define
greetafter the class body - Rename the
selfparameter tocls - Return
namewithout the greeting
A method belongs in the class body; assigning a stray function is fragile and confusing.
Play Problem Solving ▸