How To: Lists: Basics


Things that are alike

Putting values into variable containers can help when programming because it means we don't have to remember the precise values any longer. But what if we have several values that are alike?

For example: imagine we're helping a teacher track students' grades on assignments. One student's grades might look like: 97, 62, 85, 76, 99, and 93.

We could save all those grades in variables, like this:

but that seems tedious – we'll have to keep making new grade variables, and we'll have to remember what we called each one, too. (Remember that if we call two container variables by the same name, we'll overwrite the older one.)

Wouldn't it be better if we could store together all that values that go together?