3 Antworten
+ 22
https://docs.python.org/2.3/whatsnew/section-slices.html
15 Extended Slices
+ 9
I found the most effective way to learn list slicing is just to experiment
https://code.sololearn.com/cXNzv56rgiyL/?ref=app
+ 3
list[a:b:c] gives a new list by taking every c element from a to b.
Example:
nums = [67, 46, 28, 59, 32, 48, 19, 46]
nums[2:5:2]
[28, 32]
If a and b are omitted they default to the beginning and the end of the list