[issue39240] keyerror in string format
Raymond Hettinger
report at bugs.python.org
Mon Jan 6 20:19:28 EST 2020
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
Instead of doing lookups with square brackets, consider using the dict.get() method that returns a default value rather than raising a KeyError for a missing key.
composer2[input1] --> composer2.get(input1, 0)
----------
nosy: +rhettinger
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39240>
_______________________________________
More information about the Python-bugs-list
mailing list