In this 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 Python List Length with an example. Below, we will find the length of a string list.
The output of this Python List Length code will be 5. Because, there are 5 members of the string list.
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.
The output of this python code will be 8. Becasue there are 8 members of this python number list.
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:
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.
We can use python len() function also like below:
The output will be 6 for this code.
We can use this for string list also.
The output of this python code will be 4.
In this lesson, we have learned one of the most important python function, python len () function. We have learned how to find Python List Length. 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.