Replace (by condition?)

I have a structured list (in this example there are three numbers in each sub-list)

If one of the numbers == 0 I want to replace it depending on which index it’s at.

So if it’s at index [0] I want to replace it with 3500
if it’s at index [1] I want to replace it with 4000

This is what I have so far… But the ReplaceByCondition has no levels. :anguished:

@Alien Try this:

[x[0]==0?3500:x[0],
x[1]==0?4000:x[1],
x[2]==0?5000:x[2]];
1 Like

Take your list. Transpose. You’ll then have 3 lists running parallel.
Do your ReplaceByCondition on the 2nd list.
Then transpose back.

Or just do it in python which is more straightforward.

This should give you the right idea.

1 Like

Heh, I tried it like this but the List.GetItemAtIndex doesn’t seem to like nested lists…

So it works how you suggested :slight_smile:

However I won’t always have a list of length 3. Any suggestions how to do it with x length list… Should I just resort to Python?

Just duplicate your replacement values so your lists match. Problem solved.

4 Likes

Love this! :heart_eyes:

So neat!! Thank you!