Can someone explain this?


#1



Traceback (most recent call last):
File "python", line 11, in
File "python", line 8, in display_car
ValueError: unsupported format character 'w' (0x77) at index 16


I already don't know what am I doing at this exercise! Can someone explain what's wrong with ym code and how line continuation works? I've checked the forum but saw a lot of strange and confusing ways of describing the print statement!
Thanks in advance!


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.model, self.color, str(self.mpg))

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


#2

string placeholders are %s, not s%


#3

I am very glad it's you again but I am sure, you are not glad about that its me again! :grin: :smiley:
After chaning the string holders I got this error message:
It looks like you didn't print "This is a silver DeLorean with 88 MPG.".
But the message is in the console! What's wrong with it??


#4

you print:

This is a DeLorean silver with 88 MPG.

that almost sounds like the name of the car is silver, and the color is DeLorean.


#5

Yes, I saw it and corrected it! I've just didn't pay enough attetion.. Anyway thank you for the help again!


#6

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