Guest User

Untitled

a guest
Dec 14th, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. In [32]:  a=[1,2,3]; i=3
  2. In [33]: '{a}'.format(**locals())
  3. Out[33]: '[1, 2, 3, 4]'
  4. In [34]: '{a[i]}'.format(**locals())
  5. TypeError: list indices must be integers, not str
  6. In [35]: '{a[{i}]}'.format(**locals())
  7. TypeError: list indices must be integers, not str
  8. In [36]: '{a[{0}]}'.format(3, **locals())
  9. TypeError: list indices must be integers, not str
  10.  
  11.  
  12. In [37]: '{a[0]}'.format(**locals())
  13. Out[37]: '1'
Advertisement
Add Comment
Please, Sign In to add comment