Skip to content

Glossary: Python Basics

Counting pattern

Also written: counting with a dictionary

Using a dict to count things with `counts[x] = counts.get(x, 0) + 1`, so a new key starts from 0. Adding an amount instead of 1 gives totals per key.

Where the book teaches it

Related terms

.get()