Creating class methods


#1

this is my code:

class Car(object):
condition = "new"
def __init__(self, model, color, mpg):
    self.model = model
    self.color = color
    self.mpg   = mpg
def display_car(self):
    return "This is a %s %s whith %s MPG." % (self.color, self.model, str(self.mpg))

my_car = Car("DeLorean", "silver", 88)
print my_car.display_car()

my output is:
This is a silver DeLorean whith 88 MPG.
None

and i get the error:
Oops, try again. It looks like you didn't print "This is a silver DeLorean with 88 MPG.".

i dont get it


#2

i found it "with" != "whith" :smile:


#3

could you please clarify getting the same error

class Car(object):
condition = "new"
def __init__(self, model, color, mpg):
    self.model = model
    self.color = color
    self.mpg   = mpg
    
def display_car(self):
    print"This is a %s %s with %s MPG" %(self.color, self.model, self.mpg)

my_car = Car("DeLorean", "silver", 88)
print my_car.condition

print my_car.display_car()


#4

sorry had forgotten to put a full stop .