Python Developer — Medium
Key points
- Negative indexing in Python starts from the end of the list
- a[-1] accesses the last element of the list
- a[-2:] accesses a sublist starting from the second-to-last element
- The output includes the last element and a sublist from the second-to-last element to the end
Ready to go further?
Related questions
