1) You can use defaultdict from collections
2) A missing key is a bigger issue in applications, which should in fact raise errors sometimes (as debugging in Python can already be difficult)

Alibek Cholponbaev
Alibek Cholponbaev

Written by Alibek Cholponbaev

Database Developer & Data Engineer. Passionate about technologies, self-improvement and making the world a better place.

No responses yet