Codecademy error on print statement


My original print statements that failed the test:

print "This is a", self.color, self.model, "with", str(self.mpg), "MPG."
print "This is a", self.color, self.model, "with", self.mpg, "MPG."

Codecademy would not accept the answer unless I did this:

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

However, the output is indistinguishable among the three statements.
Why is it rejecting the first two and how does it even know the difference?



Although the two outputs appear identical, Codecademy is looking for output that is composed of a single unified string. Technically, the output produced by this line consists of six strings, because it specifies six values, separated by commas, that are to be output ...

print "This is a", self.color, self.model, "with", str(self.mpg), "MPG."

Your second line of code, which was accepted, unifies the output into a single string.


don't forget the full stop either like me.


Thanks. How does the answer checker know whether a line is a single string or multiple strings?

Why not accept both to avoid confusion?