SUBSTITUTE string values in a list by boolean

hello to everybody

i’m trying to substitute alle the values of the list below whit a new string whether the boolean mask say true or false but cant figure out how to do it, i’ve tried whit replace item by condition but dosent work…
any idea?

Assuming you want to replace the entirety of the string with one value or another, and not just change out some of the text, an If node should do the trick.

The test input is the result of the boolean mask.
The value of true is the true input.
And the false input is what you want to say if false.

You could also use a design script code block (double click on the canvas to place the node) and type something like the following (not at a PC to test anything): initialString.Contains(searchFor, false) ? trueValue : falseValue;.

The inputs to that are your initial string, the thing you want to search for, the value if true and the value if false.

2 Likes

This might satisfy your requirement.

Python Script
def Boolean_Check(items_list):
    result = []
    for item, boolean_value in zip(Incoming_Strings, Incoming_Booleans):
        if boolean_value == False:
            result.append(String_Replacement)
        else:
            result.append(item)
    return result

Incoming_Strings = IN[0]
Incoming_Booleans = IN[1]
String_Replacement = IN[2]

Amended_String = Boolean_Check(Incoming_Booleans)

OUT = Amended_String

1 Like

thanks alot pyXam, i would like to learn the basic of python for be able to wrigt those short script by my oun, do you have any suggestion, link? yt toutorials?

thansk again

There is certainly a lot out there with regard to where / how to learn.

for python in general you could start here :slight_smile:

After that, give Gavin Grumps Pyhton 101 a crack.

1 Like