• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $249 (🏆Lifetime Access) - View offer

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

Moderator
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