Until now, you have worked with variables that store a single value at a time, a number, a text string, or a boolean.
But real programs often need to handle many values at once.
Imagine you want to store the names of 30 students, the prices of 100 products, or the daily temperatures of a whole month.
Creating 30, 100, or 31 separate variables would be impractical and impossible to manage.
This is exactly the problem that lists, also called arrays or tables, solve.
A list is a data structure that stores multiple values under a single name.
Each value inside the list is called an element.
Instead of writing many individual variables, you group all related values into one ordered collection.
For example, instead of student1, student2, student3, you write a single list called students that contains all of them.
What is a list? A list is an ordered collection of elements.
Ordered means each element has a fixed position, and that position never changes unless you deliberately modify the list.
Because the list is ordered, you can access any element by its position number, which is called the index.
A very important rule to memorize.
In almost all programming languages, including JavaScript and Python, indexing starts at 0, not at 1.
This means the first element is at index 0. the second element is at index 1, the third at index 2, and so on.
This is a classic source of beginner mistakes, so keep it firmly in mind.
Read the full transcript.
Create an account to read the whole episode, search across every transcript, and follow the shows you care about.
Until now, you have worked with variables that store a single value at a time, a number, a text string, or a boolean.
But real programs often need to handle many values at once.
Imagine you want to store the names of 30 students, the prices of 100 products, or the daily temperatures of a whole month.
Creating 30, 100, or 31 separate variables would be impractical and impossible to manage.
This is exactly the problem that lists, also called arrays or tables, solve.
A list is a data structure that stores multiple values under a single name.
Each value inside the list is called an element.
Instead of writing many individual variables, you group all related values into one ordered collection.
For example, instead of student1, student2, student3, you write a single list called students that contains all of them.
What is a list? A list is an ordered collection of elements.
Ordered means each element has a fixed position, and that position never changes unless you deliberately modify the list.
Because the list is ordered, you can access any element by its position number, which is called the index.
A very important rule to memorize.
In almost all programming languages, including JavaScript and Python, indexing starts at 0, not at 1.
This means the first element is at index 0. the second element is at index 1, the third at index 2, and so on.
This is a classic source of beginner mistakes, so keep it firmly in mind.