I’m currently stuck on this exercise and require some help.
https://www.codecademy.com/courses/learn-python/lessons/classes/exercises/creating-class-methods?action=lesson_resume&link_content_target=interstitial_lesson
The error message that keeps coming out of my code is :
Traceback (most recent call last):
File “python”, line 12, in
File “python”, line 9, in display_car
TypeError: not all arguments converted during string formatting
I am unsure how to convert the mpg to a string format. I shall paste my code at the bottom:
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, self.mpg)
my_car = Car("DeLorean", "silver", 88)
print my_car.display_car()
UPDATE : SORRY IT WAS A TYPO THAT CAUSED THE ERROR, THIS POST CAN BE CLOSED NOW. SORRY