What does %s and % do


#1

for fruit in prices:

  print fruit
  print "price: %s" % prices[fruit]
  print "stock: %s" % stock[fruit]

What does %s and % do again, in this context? I forget.

Sorry if I posted this in the wrong place.


FAQ: Learn Python: A Day at the Supermarket - Keeping Track of the Produce
FAQ: Learn Python: A Day at the Supermarket - Keeping Track of the Produce
#2

Go back and review Strings and Console Output for the subject of string formatting.

%s

is a string value placeholder,

% ()

is the argument list.


#3

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