Log in from a computer to take this course

You'll need to log in from a computer to start Learn Python 3. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

Often, we’ll need to find the number of items in a list, usually called its length.

We can do this using a built-in function called len().

When we apply len() to a list, we get the number of elements in that list:

my_list = [1, 2, 3, 4, 5] print(len(my_list))

Would output:

5

Let’s find the length of various lists!

Instructions

1.

Calculate the length of long_list and save it to the variable long_list_len.

2.

Use print() to examine long_list_len.

3.

We have provided a completed range() function for the variable big_range.

Calculate its length using the function len() and save it to a variable called big_range_length.

Note: Range objects do not need to be converted to lists in order to determine their length

4.

Use print() to examine big_range_length.

5.

Change the range() function that generates big_range so that it skips 100 instead of 10 steps between items.

How does this change big_range_length?

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?