How to Access List Items in Python


In this example, we will learn how to access the list items by specifying an negative index range in Python.

Source Code

my_list = ['a', 'b', 'c', 'd', 'e']
print(my_list[-4:-1])

Output:

['b', 'c', 'd']
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Advertisement