Python Tutorials · Python Lists

Access List Items

Learn all about Access List Items in this comprehensive tutorial.

5 min read beginner
  • List items are indexed and you can access them by referring to the index number:
  • To determine if a specified item is present in a list use the in keyword:

Access Items

List items are indexed and you can access them by referring to the index number:

python
Note: Note: The first item has index 0.

Negative indexing means start from the end

-1 refers to the last item, -2 refers to the second last item etc.

python

You can specify a range of indexes by specifying where to start and where to end the range.

When specifying a range, the return value will be a new list with the specified items.

python
Note: Note: The search will start at index 2 (included) and end at index 5 (not included).
Note: Remember that the first item has index 0.

By leaving out the start value, the range will start at the first item:

python

By leaving out the end value, the range will go on to the end of the list:

python

Specify negative indexes if you want to start the search from the end of the list:

python

Check if Item Exists

To determine if a specified item is present in a list use the in keyword:

python

Module quiz

2 questions
1

Which of the following is true about Access List Items?

2

What is the most common pitfall when working with Access List Items?

Answer all questions to submit.