Python - Classes and Object Lifecycle
Find the error in this class definition:
class Car:
def __init__(self, model):
model = model
c = Car('Tesla')class Car:
def __init__(self, model):
model = model
c = Car('Tesla')self is present, so no error there.__init__, model = model assigns parameter to itself, not to the object. It should be self.model = model.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions