Python List Length

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.


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


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.


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


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:


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


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:


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


The output will be 6 for this code.




We can use this for string list also.


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


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.


Back to: Python Programming Course > Python Lists

Leave a Reply

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


IPCisco is the Winner! “Best Certification Study Journey of 2019!”


Python Programming Course