I have the following code. I can't find the way of creating a new key and append a number to the value list.
from typing import Dict, List, Set
diccionary: Dict[str, List[int]]
diccionary = {}
diccionary["key"].append(2)
diccionary["key2"].append(4)
diccionary["key2"].append(1)
print(diccionary)
When I run this code I get:
Traceback (most recent call last):
File "diccionario.py", line 5, in <module>
diccionario["key"].append(2)
KeyError: 'key'