Studyfin Studyfin ✨ Sign up free

Lists & arrays

Grade 8 · Coding · Free lesson

Hey there! Ready to level up your coding skills? Let's explore how programmers store groups of items together using lists!

In coding, a list or array is a tool that lets us store multiple items inside a single variable name. Instead of creating ten different variables for ten items, we can keep them all in one organized place.

check list

Every item in a list has a specific position called an index. In programming, we almost always start counting our index positions at zero instead of one.

"Apple" Index 0 "Banana" Index 1 "Cherry" Index 2

We can easily change, add, or remove items from our list at any time. This makes lists perfect for keeping track of high scores, inventory items, or player names in a game.

My Inventory List 1. Shield 2. Sword 3. Potion +
✏️ Worked example

Imagine you are making a video game. You want to store a list of three player names: Alex, Sam, and Taylor. Let's write down the steps to create this list and find the name stored at index 1.

  1. First, we define our list variable and give it a name, like 'players'.
  2. Next, we assign the three names to our list inside square brackets: players = ["Alex", "Sam", "Taylor"].
  3. Now, we identify the index positions. Remember, we start counting at 0!
  4. "Alex" is at index 0, "Sam" is at index 1, and "Taylor" is at index 2.
  5. To find the name at index 1, we look at our list and select "Sam".
books list
Want the full interactive lesson — quiz, animations, and Finn cheering them on?

More Coding lessons