6/11 Referring to Member Variables



Here is the error message:

Traceback (most recent call last):
File "python", line 8, in
TypeError: object.new() takes no parameters

This message comes up too:

Make sure you pass the self keyword to the init() function.


My code:

class Car(object):
condition = "new"
def init(self, model, color, mpg):
self.model = model
self.color = color
self.mpg = mpg

my_car = Car("Delorean", "silver", 88)
print my_car.condition
print my_car.model
print my_car.color
print my_car.mpg


Hi thsi line

my_car = Car("Delorean", "silver", 88)

the model of the car should be "DeLorean". instead of "Delorean" with the uppercase L


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.