How to Find Size of List Items or Get Length in Python

In this tutorial, learn how to find size of list item using Python. The short answer is: Use the Python len() function to get the length of list items. The elements of the list variable are the items enclosed within the single or double quotes.

A list variable may contain elements same as the element we find in an array in other programming languages like Java. You may also like to read how to create variables in Python to create other types of variables.

How to Find Size of List Items in python

To find the length of the list variable in Python, you have to use the len() function. Inside the len(), you have to pass the list variable as the argument of it.

Now, if you print the combination as given in the example below. You will get the exact number of the list items available in the list variable. It counts the string as well as the integer and float items of the list variable of Python.

Output

6

The above example gives 6 as the output of the len() function. There are six elements inside the list variable. However, you can add more items to the list in Python. After that, you have to use the Python print statement to find the size of list items and print the length in the output.

You may also like to read

Hope, you like this tutorial of how to get the length and find size of list items in Python. If you have any query regarding the tutorial, please comment below.

References

Also tell me, which method you are using to get the length of the list items in Python.

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.