# Python List Length In this Python coding lesson, we will learn how to find Python List Length with various examples. To find the length of a python list is an important function for various algorithms. We will use len() fucntion to find the length of a python list. You can use this function in different algorithms for various aims.

Let’s start to learn finding List Length with an example. Below, we will find the length of a string list.

``````animals = ["wolf", "bear", "eagle", "gorilla", "tiger"]
length = len(animals)
print(length)``````

The output of this Lentgh of List code will be 5. Because, there are 5 members of the string list.

``5``

You can also check Python List Comprehension Let’s do an example, with numbers and a number list. In this example, we will find the lentgh of the number list with python len () function.

``````numbers = [4,6,17,23,45,56,79,92]
length = len(numbers)
print(length)``````

The output of this python code will be 8. Becasue there are 8 members of this python number list.

``8`` Let’s do a Python List Length example, with a list consist of both numbers and strings. Here, we will use the belowm python code:

``````list = [15, "cats", 63, "dogs"]
length = len(list)
print(length)``````

As a return fom this code, we will receive 4. Because there are 4 members of this mixed list. Two ıf them are numbers and two of them are strings.

``4``

We can use python len() function also like below:

``````length = len([4, 7, 12, 35, 44, 78])
print(length)``````

The output will be 6 for this code.

``6``

We can use this for string list also.

``````length = len([“Audi”, “BMW”, “Mercedes”, ”Volvo”])
print(length)``````

The output of this python code will be 4.

``4`` In this lesson, we have learned one of the most important python function, python len () function. We have learned how to find Length of a Python List.  We can use this important function in various codes and algorithms not only to learn the length of a string but also for various purposes.

Back to: Python Programming Course > Python Lists

Collapse
Expand