https://developers.google.com/edu/python/lists?hl=en
https://docs.python.org/2/tutorial/datastructures.html
http://www.tutorialspoint.com/python/python_lists.htm
List range (Important)
https://deron.meranda.us/python/tutorial-bazaar/chapter2
s[ first:last ]. The last index is not included, but included if last idex is omitted such as s[first:]
Sublist:
L = [ "A", "B", [ "X", "Y" ], "C" ]
print L[-1] --> "C"
print L[2] --> ["X", "Y"]
print L[2][-1] --> "Y"
print len(L) --> 4
Sequence types: strings, lists, and tuples
If you pass in a negative index, Python adds the length of the list to the index. L[-1] can be used to access the last item in a list.
a=[1,2,3]
a[-1] = a[3-1]
If you need both the index and the item, use the enumerate function:
No comments:
Post a Comment