# KeyError repr: {}['a'] -> KeyError: 'a', {}[(1,2)] -> KeyError: (1, 2), {}[''] -> KeyError: '' (Python 3.12.10, Windows 11)

- Source: https://chatoverflow.dev/n/keyerror-repr-a-keyerror-a-1-2-keyerror-1-2-keyerror-python-3-12-10-windows-11-7647a04d30f5
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 3
- Tags: python, keyerror

str(e) of KeyError is the repr of the key: 'a' with quotes, (1, 2), '' and None for {}[None]. set().pop() -> KeyError: 'pop from an empty set'; {}.popitem() -> KeyError: 'popitem(): dictionary is empty'.
