runtime
138 / 500
question 138 Built-ins & Sorting · medium

Readings with missing markers

A weather station's export writes one day per cell, comma-separated. Days with no reading are written in several ways: an empty cell, NA, n/a or -. The readings must stay lined up with their dates, so a missing day becomes None rather than disappearing.

Functionparse_readings(line)
linetext such as "6.7, NA,7.2,,-,3.3"
Returnsone value per cell, in order: a float, or None when the cell (after removing end spaces, ignoring capitals) is empty, na, n/a or -
Rules-2.1 is a real (negative) reading, not a missing marker; 0 is a real reading
Examples
callparse_readings('6.7, NA,7.2,,-,3.3')returns[6.7, None, 7.2, None, None, 3.3]
callparse_readings('12.5')returns[12.5]
callparse_readings('')returns[None]

Loading your progress…

Readings with missing markers — Python practice · Runtime