Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >t = ['a', 'b', 'c', 'd']
- ># 0 1 2 3 indexes to the left of values
- >t[0] # access the value to the right of index
- 'a'
- >t[0:2] # slice the list from index 0 to index 2
- ['a', 'b']
- >t[1:] # slice the list from index 1 to the end
- ['b', 'c', 'd']
- >t[1:-1] # slice the list from index 1 to one but last
- ['b', 'c']
- >t[:] # create a copy of the list
- ['a', 'b', 'c', 'd']
- ># | a | b | c | d | a | b | c | d | value
- ># -4 -3 -2 -1 0 1 2 3 4 indexes
Advertisement
Add Comment
Please, Sign In to add comment