How to swap values in a list with a conditional statement?

I would like to swap values in a list, and I haven’t been able to find exactly how to create a conditional swap, where if one value equals say 270 I would like to swap it for 90, but if the value is the reverse ie it equals 90 I would like to swap it for 270, the code, I believe involves an if-condition then, and an elseif-condition then, but I have been able to find how to create it.
Any help here will be appreciated. In the sample the other values remain unchanged, ie 0, 180 do not change.

SWAP_LIST_VALUES.dyn (4.9 KB)

You can use nested if statements within an if statement.


In the picture, in the if?true:false;, you can put another if statement in the false section. Here I put a==90?270:a into the false.

6 Likes

@kennyb6

Thankyou Kenny,

Your help has solved a lot of pain for me, so elegant and so simple. I truly appreciate your quick response.

2 Likes