Fill None Values
Start Timer
0:00:00
Given a sorted list of positive integers with some entries being None
, write a function to return a new list where all None
values are replaced with the most recent non-None
value in the list.
Note: If the first entry in the list is None
, assume the previous entry was 0
.
Example:
Input:
input_list = [1,2,None,None,4,5,None]
Output:
def fill_none(input_list) -> [1,2,2,2,4,5,5]
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments