Module 1.1 Python, Introduction to Lists

What is a List?

A list is a data structure that stores multiples values (data) all in one place. This can be very beneficial compared to regular variables that can only store one value at a time.

Regular variables have many uses. For example:

  • Store a username
  • Store a sentence
  • Store the result a math calculation
  • Store an on/off switch
  • Store input from the user

However, once we start needing multiples regular variables to store data that is similar to one another, it can start to get confusing. For example, storing food items you want to buy at the grocery store.

When we start writing code like this, we know it is a good time to use a list instead of regular variables.

Anytime you see square brackets, [ ], you know you have a list!

Situations where we would want to use a list:

  • Storing multiple usernames
  • Storing multiple inputs
  • Storing multiple test scores