

Signal Parser
A sensor log arrives as lines like "altitude=1200". Write parse_readings(lines) that returns a dict with two keys:
"values": a dict from each reading name to its whole-number value"bad": how many lines could not be parsed
A line is bad if it has no = or its value is not a whole number. Ignore spaces around the name and the value. If a name appears twice, keep the later value. Use try/except for the conversion.
Examples
parse_readings(['altitude=1200', 'speed=340'])
→ {'values': {'altitude': 1200, 'speed': 340}, 'bad': 0}
parse_readings(['temp=-4', 'oops', 'wind=fast'])
→ {'values': {'temp': -4}, 'bad': 2}
solution.py
PYTHON
Saved as you type
Tests
0 of 5 passing- •two good linesparse_readings(['altitude=1200', 'speed=340'])expected {'values': {'altitude': 1200, 'speed': 340}, 'bad': 0}
- •bad lines are countedparse_readings(['temp=-4', 'oops', 'wind=fast'])expected {'values': {'temp': -4}, 'bad': 2}
- •empty logparse_readings([])expected {'values': {}, 'bad': 0}
- •later value winsparse_readings(['a=1', 'a=2'])expected {'values': {'a': 2}, 'bad': 0}
- •spaces are ignoredparse_readings([' depth = 30 '])expected {'values': {'depth': 30}, 'bad': 0}
On the line
+60 XP
Pass all 5 tests to claim it.
