Creating Cl*ss methods


#1



https://www.codecademy.com/en/courses/python-intermediate-en-egNXj/1/1?curriculum_id=4f89dab3d788890003000096#

How is this wrong, it prints what it should, yet I keep getting an error message


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 with %s MPG"%(self.color,self.model,str(self.mpg))

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


#2

Hi @teehee23456789,

Check the entire output. It must exactly match the specifications. Every character is significant, including what is at the very end of the sentence.


#3

It printed perfectly fine, there were no extra characters.


#4

This statement does not provide a period at the end of the result ...

    return "This is a %s %s with %s MPG"%(self.color,self.model,str(self.mpg)

However, the instructions ask for this format ...

"This is a [color] [model] with [mpg] MPG."


#5

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