Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Say whether a list or a dictionary is the better choice for each, and why.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Ask: do I find the items by position, or by a name?
Check. A good test: if you would write "find the ... of ..." with a name, a dictionary fits. If you would write "the third ...", a list fits.
Answer: list, dictionary, dictionary, list.
Log in to join the discussion.
Loading…