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.
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.