Lists
At the end of the last lesson, you saw how the for loop gave you the power to loop through a list of items. In this lesson, you’ll learn more about working with lists, and see how lists and loops together make for powerful programming patterns.
You’ll also focus on problem-solving using loops, and practice breaking problems down into pieces so that you can find solutions step by step.
Topics covered
Here's a preview of what you'll learn this week:
- Lists store multiple pieces of data, like
[1, "hello", [ "another list" ], False] - You access list elements by their index, which starts at 0, like
my_list[0] - You can change list contents by assigning at an index, appending, or removing elements
- assigning:
my_list[0] = 5 - appending
my_list.append(10) - removing
my_list.pop(2)
- assigning:
- You can solve many problems (like the ones below) by updating a variable at each step in a loop
- total and average
- maximum and minimum
- finding and filtering