# fancyDicts

### OrderedDict

keeps order of insertion

```python
from collections import OrderedDict
```

### DefaultDict

Creates default, nonnull value for keys

```python
from collections import defaultdict
d = defaultdict(list)
for k, v in somePairs:
    d[k].append(v)
```

### Counter

Counts elements

```python
from collections import Counter
c = Counter("hell") #Counter({'l': 2, 'h': 1, 'e': 1})

#Add iterables of values
c.update([1, 3, 4])
c.most_common(10) # 10 most common
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openai.gitbook.io/code-cheatsheets/all/python/collections/fancydicts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
