Mapping Keys to Multiple Values in a Dictionary #100 - Dois Passos a Frente

Share:

Listens: 0

Dois Passos a Frente

Comedy


A dictionary is a mapping where each key is mapped to a single value. If you want to map keys to multiple values, you need to store the multiple values in another container such as a list or set; To easily construct such dictionaries, you can use defaultdict in the collections module. A feature of defaultdict is that it automatically initializes the first value so you can simply focus on adding items;