Drop the Failed Sensor Reads

Easy ⏱ 8 min 78% acceptance ★★★★☆ 4.4
Failed sensor reads arrive as None; valid ones are numbers (including 0 and negative values, which must be kept). Write valid_reads(readings) using filter — note that filter(None, ...) would wrongly drop 0, so write an explicit lambda.

Examples

Example 1
Input
valid_reads([3, None, 0, -2, None])
Output
[3, 0, -2]
Explanation

0 is a legitimate reading; only None disappears.

Constraints

  • Keep zeros and negatives.
  • Use filter with a lambda.

Topics

Lambda & Functionalfilter None

Companies

CiscoIntelBosch

Hints

Hint 1

filter(None, seq) removes ALL falsy values — too aggressive here.

Hint 2

lambda r: r is not None.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.