Python - Constructors and Object Initialization
Identify the error in this code snippet:
class Car:
def __init__(self, model):
model = model
c = Car('Tesla')
print(c.model)Identify the error in this code snippet:
class Car:
def __init__(self, model):
model = model
c = Car('Tesla')
print(c.model)model = model, which only reassigns the local variable, not the instance attribute.self.model is never set, c.model does not exist, causing an error.c.model does not exist. -> Option A15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions