Learn

At this point, we assume that you’re familiar with arrays: they’re useful tools for managing large amounts of sequential data.

But arrays have their drawbacks:

  • They have a limited length
  • You have to keep track of the number of elements in the array using a separate index
  • You can only edit one element at a time

Lists resolve all of these issues! Like arrays, they are a sequential collection of values and they can hold references to any type. Unlike arrays, they have (effectively) unlimited length, they automatically track the number of actual elements in the list, and they have handy methods to work with multiple elements at a time.

In this lesson we’ll cover list basics and some common list methods.

Instructions

1.

This code creates and edits a lists of cities. How does this look different from arrays?

Run the code to see it in action.

Take this course for free

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?