Creating class methods: Is this a bug? It prints exactly what it's supposed to print, and it throws an error saying it doesn't


#1




When I run the code, it throws this error:
Oops, try again. It looks like you didn't print "This is a silver DeLorean with 88 MPG.".
This is the output in the console.
This is a silver DeLorean with 88 MPG.
None
None

It's odd because this is exactly what it says to print.

Here's 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):
        print 'This is a', self.color, self.model, 'with', str(self.mpg), 'MPG.'
my_car = Car("DeLorean", "silver", 88)
print my_car.display_car()


#2

What if you were to print using modulo formatting?


#3

Thanks. Sorry, I forgot to close it, but modulo formatting worked. :confused:


#4

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