All you need to know about List Slicing in Python

List indexing starts from 0. For list of length n . Indexing will range from 0 to n-1.
At index/position/address/location 3, we have element 4. So output is 4.
Here step size is 2, so it jumped to next to next index .
This will return elements at 0,4,8,12,16…etc (Depends on list size, in this example list is of size 7. So 0,4 location elements will be in output)
[1,2,3,4,5,6,7]Indexing from right to left is
[-n,-n+1,...,-1]
In this example its going to be
[-7,-6,-5,-4,-3,-2,-1]

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store