Initializing a Class


#1



I am not sure why it keeps saying that i did not pass 3 arguments. When i printed it out, i managed to get DeLorean silver 88


Keep getting this error
Oops, try again. You need to pass three arguments when creating a new Car().


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

#my_car = Car()
my_car = Car("DeLorean", "silver", 88)

print my_car.model, my_car.color, my_car.mpg


#2

here:

#my_car = Car()

even though a comment, the exercise still sees that initalize a class with 0 arguments

remove the comment


#3

Got it. Does this exception only applies to instance of a new class, or other things as well?


#4

There was another exercise where this problem occurs as well.


#5

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