Categories
Python Answers

How to get the number of elements in a list with Python?

Spread the love

Sometimes, we want to get the number of elements in a list with Python.

In this article, we’ll look at how to get the number of elements in a list with Python.

How to get the number of elements in a list with Python?

To get the number of elements in a list with Python, we can use the len function.

For instance, we write:

print(len([1, 2, 3]))

then we see 3 printed since our list has 3 items.

Conclusion

To get the number of elements in a list with Python, we can use the len function

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *