Have you seen the error below?
1 2 3 4 5 6 |
Traceback (most recent call last): File "C:/Users/foo/PycharmProjects/pythonProject3/main.py", line 29, in <module> main() File "C:/Users/foo/PycharmProjects/pythonProject3/main.py", line 19, in main a['foo'] += 5 KeyError: 'foo' |
Of course you have. And you know, that it is because you have written something extremely unwise like this:
1 2 |
a = dict() a['foo'] += 5 |
Yeah. You cannot increment the value of a non-existent key. Unless… Unless you…