Define_car


#1

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)
    #alternatively print "This is a " + self.color + " " + self.model + " with " + str(self.mpg) + " MPG"

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

my_car.display_car()

Both solutions give out "This is a silver DeLorean with 88 MPG", but it still says, that i didn't put out the right answer...


#2

You need to convert 'mpg' to a string in your print statement. The way it does in the comment on your code. use str(self.mpg)).

print 'This is a %s %s with %s MPG.' % (self.color, self.model, str(self.mpg))   #<<<

see if that works :smile:


#3

Still doesn't work. I get the right output, but somehow it just doesn't count.


#4

You missed full stop after MPG in your print statement. Add that and the code will work.