Intermediate
Drop values the source text does not support
Write keep_only_evidence(data, source). data is a dictionary of extracted fields and source is the original text. Return (kept, removed).
kept is a new dictionary with the same keys. A string value that does not appear in source (compare ignoring upper and lower case) becomes None. Values that are already None, or are not strings, stay as they are. removed is the list of keys whose value was replaced, in the order of data.
What Check tests
- Supported values stay
- An invented value becomes None and is reported
- Case does not matter
- None and numbers are left alone
- The input dictionary is not changed
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.