I\'m currently re-engaging with Python after a long absence and loving it. However, I find myself coming across a pattern over and over. I keep thinking that there must be a
The dict's get() method takes an optional second parameter that can be used to provide a default value if the requested key is not found:
dict
foo[bar] = foo.get(bar, 0) + 1