Help, It keeps giving an indentation error, i don’t see what i’m doing wrong.

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.model
print my_car.color
print my_car.mpg

 def display_car(self):
    print "This is a %s %s with str(%s) MPG" %s (self.model, self.color, self.mpg)
print my_car.display_car


display_car is a method of Car class, so it should be after the init method and before the class instance (my_car)

also, %s is a string placeholder, so need to cast to string

self.mpg is a integer, which you need to cast to string


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