+ 3

What is meant by list[::2] in Python ?

I was wondering when I came across a question in Python where it asked about the answer of above . it seems like a list operation but I didn't understand

28th Jan 2018, 8:21 AM
Nerd
Nerd - avatar
3 Antworten
+ 22
https://docs.python.org/2.3/whatsnew/section-slices.html 15 Extended Slices
28th Jan 2018, 8:26 AM
Nithiwat
Nithiwat - avatar
+ 9
I found the most effective way to learn list slicing is just to experiment https://code.sololearn.com/cXNzv56rgiyL/?ref=app
28th Jan 2018, 8:49 AM
David Ashton
David Ashton - avatar
+ 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
28th Jan 2018, 8:27 AM
Vlad Serbu
Vlad Serbu - avatar