How do you display a number of items in a list in Python?

Experience Level: Junior
Tags: Python

Answer

To get a number of items in a list, use len().

Example:

items = list["red", "amber", "green"]
number_of_items = len(items)
print(number_of_items)

Python for beginners
Python for beginners

Are you learning Python ? Try our test we designed to help you progress faster.

Test yourself