Post

@PythonPr Answer: A
Solution: This is an application of slicing and negative indices.
You must be familiar with the usual indexing that starts from 0 (starting from the left).
Negative indexing is a cool feature of python. It allows you to count backwards (from the right).
Eg
+
English

@PythonPr nums = [1, 2, 3, 4]
If you want to access the last item,
you'd have to do something like
num[len(nums)-1]
clunky and un-pythonic.
Instead, you can use -1 to access the last item, like so:
num[-1] # access last (rightmost) item
What about the 2nd-last item? Got you covered
+
English

@PythonPr You can count backwards from the rightmost item.
The 2nd-last is at index -2,
the 3rd-last at -3, and so on.
See image:
Applying to this question
+

English

@PythonPr We have a slicing, from (-3) to (-1)
ie, from 3rd-last to the last.
nums = [1, 2, 3, 4]
so, 3rd-last is 2. The last is 4.
The slice starts from the start index and excludes the stop index.
So, the output is:
[2, 3]
I hope this helped!
English

