Choose a list or a dictionary
Choose a collection by whether order or lookup by a stable key matters.
In this lesson
- It starts with a question. Do an arrival line and a stock lookup need the same kind of organisation?
- The idea you will find. A list uses positions; a dictionary uses keys. — Use a list when sequence matters, such as arrivals. A dictionary associates each unique key with a value, such as a product code and its stock count. Python list positions start at zero. A missing key is not evidence of zero stock.
- How you learn it. By doing: matching.
- Length. 8 short steps. Progress saves on this phone.
Part of Python market notebook
Follow a fictional market notebook through inputs, totals, data structures and tested functions. Complete every activity inside FijiLearn.