code_junkie

I don't understand slicing with negative bounds in Python. How is this supposed to work

Nov 13th, 2011
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.14 KB | None | 0 0
  1. >>> s = 'spam'
  2. >>> s[:-1]
  3. 'spa'
  4.  
  5. myList = ['a', 'b', 'c', 'd', 'e']
  6. print myList[-1] # prints 'e'
  7.  
  8. [beginning_index:ending_index]
Add Comment
Please, Sign In to add comment