4.1 Choosing a data structure
Python offers a number of built-in data structures to help us work with collections of data. It can be confusing to match the data structure features with the problem we’re trying to solve.
How do we choose which structure to use?
4.1.1 Getting ready
Before we put data into a collection, we’ll need to consider how we’ll gather the data, and what we’ll do with the collection once we have it. One big question is how to identify a particular item within the collection. Python offers a variety of choices.
4.1.2 How to do it...
Is the programming focused on the existence of a value? An example of this is validating an input value. When the user enters something that’s in a collection, their input is valid; otherwise, the entry is invalid. Simple membership tests suggest using a set:
def confirm() -> bool:...