indexing python first and last 1

indexing python first and last

l = [1,2,3,4,5]
l[::len(l)-1]

Here is what the above code is Doing:
1. l[::len(l)-1]
2. l[::4]
3. l[::-1]
4. l[::-1]
5. [5,4,3,2,1]

Similar Posts