You have to put the definition of
__init__ inside of the class definition.
The error is because you use a variable called
model that you never defined. If you define a variable inside of a class definiton it is only available inside of the class, not gloabaly.
Your class should look like this:
class Car(object): def __init__(self,model,color,mpg): self.model = model self.color = color self.mg = mpg
thanks so much
get confused with the code becoming longer and longer..........
No problem, I think this might help you: