Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [32]: a=[1,2,3]; i=3
- In [33]: '{a}'.format(**locals())
- Out[33]: '[1, 2, 3, 4]'
- In [34]: '{a[i]}'.format(**locals())
- TypeError: list indices must be integers, not str
- In [35]: '{a[{i}]}'.format(**locals())
- TypeError: list indices must be integers, not str
- In [36]: '{a[{0}]}'.format(3, **locals())
- TypeError: list indices must be integers, not str
- In [37]: '{a[0]}'.format(**locals())
- Out[37]: '1'
Advertisement
Add Comment
Please, Sign In to add comment