the string format(method basic usage of the str format(method looks like thisprint('we are the {who say "{}!"format('knights''ni')we are the knights who say "ni!the brackets and characters within them (called format fieldsare replaced with the objects passed into the str format(method number in the brackets can be used to refer to the position of the object passed into the str format(method print('{ and { }format('spam''eggs')spam and eggs print('{ and { }format('spam''eggs')eggs and spam if keyword arguments are used in the str format(methodtheir values are referred to by using the name of the argument print('this {foodis {adjectiveformatfood='spam'adjective='absolutely horrible')this spam is absolutely horrible positional and keyword arguments can be arbitrarily combinedprint('the story of { }{ }and {otherformat('bill''manfred'other='georg')the story of billmanfredand georg if you have really long format string that you don' want to split upit would be nice if you could reference the variables to be formatted by name instead of by position this can be done by simply passing the dict and using square brackets '[]to access the keys table {'sjoerd' 'jack' 'dcab' print('jack{ [jack]: }sjoerd{ [sjoerd]: }'dcab{ [dcab]: }format(table)jack sjoerd dcab this could also be done by passing the table as keyword arguments with the '**notation table {'sjoerd' 'jack' 'dcab' print('jack{jack: }sjoerd{sjoerd: }dcab{dcab: }format(**table)jack sjoerd dcab this is particularly useful in combination with the built-in function vars()which returns dictionary containing all local variables as an examplethe following lines produce tidily-aligned set of columns giving integers and their squares and cubesfor in range( )print('{ : { : { : }format(xx*xx* * ) (continues on next page fancier output formatting