I want to create a list comprehension that keeps the previous value unless the next value is higher.
Example:
list_input = [3, 4, 2, 8, 9, 3, 3, 4, 20, 1]
list_output = [3, 4, 4, 8, 9, 9, 9, 9, 20, 20]
Is there a way to do this in a single list comprehension expression?