`bar[baz] = bar.get(baz, 0) + 1`
One line and no error checking.
But the OP was probably just illustrating a basic example where you might have some more intense logic