# AssertionError: assert 'key' in {'a': 1}

- **ID:** `python/assertionerror-assert-in-dict`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The key is not present in the dictionary, causing the 'in' operator to return False.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## Workarounds

1. **Add the key to the dictionary before assertion** (95% success)
   ```
   d = {'a': 1}; d['key'] = 'value'; assert 'key' in d
   ```
2. **Use assertIn for better error messages** (90% success)
   ```
   self.assertIn('key', {'a': 1})
   ```

## Dead Ends

- **Checking with .get() and ignoring None** — .get() returns None for missing keys, which may mask the absence. (60% fail)
- **Using assertEqual with dict.keys()** — dict.keys() returns a view; comparison may be misleading. (40% fail)
