View counts with the missing days dropped

Code review · Medium · §10.3 Filtering and choosing

This is a list of daily view counts. Days that could not be counted were recorded as -1. The code is meant to make a new list in which those days become 0. It runs without an error, but those days are dropped completely, so there are fewer days. Fix just one line so that the output is [120, 0, 85, 0, 240] and 5.

Code to fix

views = [120, -1, 85, -1, 240]
filled = [v for v in views if v != -1]
print(filled)
print(len(filled))

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.