PY-49
Classify Parsed Rows in Rule Order
Task
Write classify_parsed_rows(records, allowed_labels). Each record is a
dictionary containing source_line, record_id, label, and value.
allowed_labels is a set of accepted non-empty labels.
Classify every record under this exact first-failure order:
- an empty label is missing:
"missing label"; - a
Nonevalue is missing:"missing value"; - a value below 0 or above 100 is rejected:
"value out of range"; - a label absent from
allowed_labelsis rejected:"unknown label"; - otherwise the record is valid.
Return a dictionary with exactly valid, missing, and rejected. valid
contains the original valid record dictionaries in source order. Each item in
the other lists is this evidence tuple:
(source_line, record_id, reason)
Every input record must appear in exactly one result category.
Example
The second record is reported as missing, not out of range, because the first failing rule determines its category and evidence.
Your implementation
Edit solution.py and keep this function signature:
Return new outer collections. Do not change a record or either input, print, or ask for input.