A formatting expression, that is an expression of the format fmt % arguments must have the correct number of arguments on the right hand side of the expression. Otherwise, a TypeError will be raised.

Change the format to match the arguments and ensure that the right hand argument always has the correct number of elements.

In the following example the right hand side of the formatting operation can be of length 2, which does not match the format string.

  • Python Library Reference: String Formatting.