dictionary-based formatting expressions as more advanced extensionstring formatting also allows conversion targets on the left to refer to the keys in dictionary coded on the right and fetch the corresponding values this opens the door to using formatting as sort of template tool we've only met dictionaries briefly thus far in but here' an example that demonstrates the basics'%(qty) more %(food) {'qty' 'food''spam'' more spamherethe (qtyand (foodin the format string on the left refer to keys in the dictionary literal on the right and fetch their associated values programs that generate text such as html or xml often use this technique--you can build up dictionary of values and substitute them all at once with single formatting expression that uses key-based references (notice the first comment is above the triple quote so it' not added to the stringand ' typing this in idle without prompt for continuation lines)reply ""greetings hello %(name)syour age is %(age) ""values {'name''bob''age' print(reply valuestemplate with substitution targets build up values to substitute perform substitutions greetings hello bobyour age is this trick is also used in conjunction with the vars built-in functionwhich returns dictionary containing all the variables that exist in the place it is calledfood 'spamqty vars({'food''spam''qty' plus built-in names set by python when used on the right side of format operationthis allows the format string to refer to variables by name--as dictionary keys'%(qty) more %(food)svars(' more spamvariables are keys in vars(we'll study dictionaries in more depth in see also for examples that convert to hexadecimal and octal number strings with the % and % formatting expression target codeswhich we won' repeat here additional formatting expression string formatting expressions