Introducing Lists to New Programmers in Scratch

When I first learned programming, I struggled to understand the concept of lists and arrays. (The exact definition of these terms varies depending on the language but I’ll be using them fairly interchangeably here.) It was not immediately clear to me why I would need a variable containing more than one piece of information when I could simply create multiple variables to do the same thing. Why would I create this:
int[] myNum = {10, 20, 30, 40};
When I could accomplish the same thing with three variables?
int myNum1 = 10;
int myNum2 = 20;
int myNum3 = 30;

The answer of course is that lists can hold much more than three pieces of information. The example above is easy to recreate with three variables. It is not so easy with 10, 100, 1,000, or even more pieces of info. It is not practical to make individual variables for lots of information.

Also, we don’t always know how many pieces of information will need to be stored so it would be very difficult to make individual variables anyway. Imagine a game where the winner had to win four of seven rounds. To track the individual rounds, you would need between 4 and 7 variables (or more depending on ties). You would not know how many variables are needed until the game is played and it will be different each game.

However, both of the above concepts can be challenging for new programmers. Lists are more complicated than variables and their use case isn’t immediately obvious – especially if you’ve already created a few games in Scratch using only variables. I was reminded of my own struggles with them when trying to introduce the concept to the coding club at my daughter’s school. Most of the kids in the room looked confused, bored, and even asked questions like, “Why do we need to know this?”

When teaching any new coding concept, I always tried to have a game or project to help illustrate it and make it more enjoyable and meaningful for the kids. But I realized quickly that my example of lists suffered from the same problems I encountered when first learning about them.

A simple example of lists
A rather boring example of using lists

This example is not very exciting. The list of foods and an index to say one of them raises the same question of “Couldn’t I just do this with some regular variables?” and “Why would I need this in my game?” There’s no reason for the learners to engage with it.

The next time I came in to teach at the coding club, I developed a small game to make the concepts more relevant. The kids seemed more interested and the lesson went much better.

Regardless, the lesson was still difficult. Lists are more difficult than many of the concepts that came before and require a solid understanding of the basics. In my experience, lists are one of the big areas where coding moves from the easy and fun activities like making a character dance or creating simple games and moves into more challenging territory that requires more study and practice. Kids can get frustrated at this point but if they stick with it, they’ll be able to do much cooler stuff.

There are a few prerequisites that you need to understand before learning lists. I’d recommend that students have a solid understanding of variables, loops, incrementing values (increasing a variable every time a loop runs), and control flow (if-then statements) in order to start using lists in more interesting ways than just storing a bunch of variables.

Prereq knowledge for lists. Incrementing variables, control flow, and loops.
If the students can explain what numbers the cat will say and why, they are ready to learn about lists.

In the coming posts, I will be linking to a few of the programs I wrote in Scratch to demonstrate lists and describe how the students responded to them.

A List Example Lesson – Percentage of Passing Tests

Leave a Comment