Lesson 2: What is a data structure
Welcome! Last lesson we met an algorithm — a list of steps. Now we'll meet something that works alongside it: a data structure. A data structure is simply a tidy way to store information so it's easy to use — just like a drawer with dividers versus a messy pile. We'll focus on the most basic structu
A data structure is like a drawer organizer: a way to arrange things so they're easy to find. A list is an ordered collection of items — you can ask for the item at a certain position, and ask how many items there are.
- data structure
- A tidy way to organize and store information so it's easy and convenient to use — like a drawer with dividers.
- index
- The number of an item's position in a list. Counting starts at 0, so the first item is at position 0.
- len
- The len command tells how many items are in a list. For example len(['a','b']) is 2.