List IndexingList Indexing

In Python, lists support element indexing. Therefore, in this case, we can access all the elements in the list using their indices. In lists, indexing starts from 0. That is, the first element has index 0, the second has index 1, and so on.

We've talked about the usual indexing. But besides this, there is also negative indexing. Negative indexing means starting from the end, i.e. index -1 refers to the last element, index -2 refers to the penultimate element, and so on.

It's time to practice.


You have the following: list_1 = ['a', 'b', 'c', 'd', 'e', ​​'f', 'g', 'h']. You need to get the first, third, fifth and seventh items in this list, and create a new list of these items using positive indices only.

Everything was clear?

Section 1. Chapter 5
toggle bottom row