What is the best way to convert negative values to 0?

nicheweb

Member
I have a number formatter math operation that subtracts two numbers and sometimes the values end up being negative. I would like to add another step that will convert any negative values to 0, but if the values are above 0, they stay the same.

What is the best way for me to accomplish this?
 

ArshilAhmad

Well-known member
Staff member
You can try adding this Python code to your workflow to achieve this use case.
1717184987655.png


Python:
def replace_negative_with_zero(numbers):
    result = []
    for num in numbers:
        if num < 0:
            result.append(0)
        else:
            result.append(num)
    return result

# Test the function
numbers = [-9]
result = replace_negative_with_zero(numbers)
print("Numbers after replacement:", result)
 
Top