Python dictionary increment May 30, 2023 by Tarik An alternative is: my_dict[key] = my_dict.get(key, 0) + num