From the course: Python Functions for Data Science

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Python len() function

Python len() function - Python Tutorial

From the course: Python Functions for Data Science

Start my 1-month free trial

Python len() function

- [Instructor] The function, len is a fundamental built-in function that is used frequently when working with data in Python. Len takes in either a sequence or a collection as input and returns the length of the given object. In other words, len returns the number of items in the given object. Now, I'll be walking through some examples to demonstrate how len can be used. First, let's say that I have a variable named list F, containing a list of some floating point numbers. To find the length of this list, I can call the function len and pass in list F, it would look like this. I'll go ahead and run this cell, as you can see, I got five as the length. Next, let's say that I have a variable named nums containing a tuple of some integers, to find the length of this tuple I can call the function len and pass in nums. It would look like this, as you can see, I got six as the length, then let's say that I have a variable…

Contents