Sal's Shipping : Get Help Video makes it worse?

“The cheapest option available is $%.2f with %s shipping.”
% (cost, method)

I have never seen this during the control flow course. How does he use variables instead of modulo sign?

And no matter what I do my code does not work.

I think the video provided makes it more complicated, especially the last part.

Edit: If someone can provide an easier path for 6th task, it would be very good.

It is covered in the unit on strings and string formatting.


is known as a directive. It is a placeholder for the first positional argument in the % tuple following the string. The cost will be represented as currency (2 decimal places). The expected input is a float.

This is one of four ways to interpolate a variable in a string.

  1. Concatenation: "The cheapest option available is "+ str(cost) + " with " + method + " shipping."
  2. Modulo: "The cheapest option available is $%.2f with %s shipping." % (cost, method)
  3. str.format(): "The cheapest option available is ${:.2f} with {} shipping.".format(cost, method)
  4. f-string: f"The cheapest option available is ${cost:.2f} with {method} shipping."

Much appreciated, thank your for your response.