String Formatting

String Formatting:
Formatting string is simply a way of presenting the information on the screen in a way that conveys the information best. Some example of formatting is creating column headers, dynamically creating a sentence from a list or stored variable, or stripping extraneous information from the strings, such as excess spaces.

>>>S="parrot"
>>>d=1
>>>print'That is %d dead %s!'%(d,s)
That is 1 dead parrot!
Translate »