I thought that %
(modulo) returned remainders from division but saw this working piece of code and now I'm confused.
Here's the code:
prices = {
"banana" : 4,
"apple" : 2,
"orange" : 1.5,
"pear" : 3
}
stock = {
"banana" : 6,
"apple" : 0,
"orange" : 32,
"pear" : 15
}
for key in prices:
print key
print "price: %s" % prices[key]
print "stock: %s" % stock[key]
My question is specifically about the last 3 lines. What does the %
do here?