7/11 creating class methods

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 %s1 %s2 with %s3 MPG." %(my_car.color, my_car.model, str(my_car.mpg))
my_car = Car("DeLorean", "silver", 88)

print my_car.display_car()`

For my mpg output I get 883!

This is the output I get and I have no idea why! please help!

This is a silver1 DeLorean2 with 883 MPG.

No numbers required with format placeholders. The values fall in the same order they appear in the tuple.

1 Like

Here is a link to a thread that discusses code sample formatting: