Sal's Shipping - How to use % in Print Command


#1

Hello folks I was just working on this exercise: [https://www.codecademy.com/paths/computer-science/tracks/cspath-flow-data-iteration/modules/dspath-control-flow/projects/sals-shipping]
and it was impossible for me to finish it as I had no clue about how we can use % in print commands.
Like below particularly;
print (
“Your cheapest option for shipping is %s shipping for &%.2f .”
% (method, cost)
)
Was this explained before in the course? I want to go back and check the explanation as I have probably missed it. If not can someone give me a link to a detailed explanation or somewhere I can figure more out about it? thanks for your help in advance!


#2

This is used in formatting strings.

Here is a link with explanation and some codeblocks where you can try out stuff yourself.

Hope it helps.


#3

Thanks so much for the link and the information!