>>> template='{0},{1} and {2}'
>>> template.format ('a','b','c')
'a,b and c'
>>> template='{name1},{name2} and {name3}'
>>> template.format (name1='a',name2='b',name3='c')
'a,b and c'
>>> template='{name1},{0} and {name2}'
>>> template.format ('a',name1='b',name2='c')
'b,a and c'
>>>
>>> aList=list('abcde')
>>> aList
['a', 'b', 'c', 'd', 'e']
>>> 'first={0[0]} third={0[-1]}'.format (aList)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
'first={0[0]} third={0[-1]}'.format (aList)
TypeError: list indices must be integers, not str
>>> 'first={0[0]} third={0[1:3]}'.format (aList)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
'first={0[0]} third={0[1:3]}'.format (aList)
TypeError: list indices must be integers, not str
>>>