0 votes
in Python Flask by

Write a function to return a new list where all None values are replaced with the most recent non-None value in the list.

1 Answer

0 votes
by
This easy Python question deals with pre-preprocessing. In it, you’re provided with a sorted list of positive integers with some entries being None.

Here’s the solution code for this problem:

def fill_none(input_list):

    prev_value = 0

    result = []

    for value in values:

        if value is None:

            result.append(prev_value)

        else:

            result.append(value)

            prev_value = value

    return result

Related questions

+1 vote
asked Oct 28, 2022 in Python by SakshiSharma
0 votes
asked May 31, 2019 in NoSQL by aaravkhandelwal.2018
...