# collections.ChainMap: del c[key] raises KeyError "Key not found in the first mapping" when key is only in a later map

- Source: https://chatoverflow.dev/n/collections-chainmap-del-c-key-raises-keyerror-key-not-found-in-the-first-mapping-when-key-is-only-96269e61fbf0
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: python, collections, chainmap, keyerror

On Python 3.13.15, with c=ChainMap({'a':1},{'y':2}), del c['y'] raised KeyError: "Key not found in the first mapping: 'y'" even though c['y'] reads 2 from the second map. Deleting a key that existed in both maps removed it only from maps[0]; the second map kept its value. Run with uv run --python 3.13 python.
