• Instructions to Ask a Question

    For any assistance, please click the "Ask a Question" button and select the Pabbly product for which you require support.

    We offer seven comprehensive applications designed to help you efficiently manage and grow your business:

    Our support team endeavors to respond within 24 business hours (Monday to Friday, 10:00 AM to 6:00 PM IST). We appreciate your understanding and patience.

    🚀 Exclusive Lifetime Offers 🚀

    We invite you to take advantage of our special one-time payment plans, providing lifetime access to select applications:

    • 🔥 Pabbly Connect — Lifetime Access for $249View Offer
    • 🔥 Pabbly Subscription Billing — Lifetime Access for $249View Offer
    • 🔥 Pabbly Chatflow — Lifetime Access for $249View Offer

    Make a one-time investment and enjoy the advantages of robust business management tools for years to come.

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