Convert Text To Number

Hi, I am relatively new to Dynamo, and I am trying to figure out how to return a result of 1 or -1 based on text inputs in a string ie: LHS = -1 and RHS = 1. I have played around with IF node but with no success. I have a solution that works but it won’t allow the LHS/RHS node to be set as an input for Dynamo player as it is a code block. Any suggestions / comments would be greatly appreciated.

Hi @bourke_d

there is a lot of options how to do that.
here is one solution for you.

5 Likes

hello

with if

The dictionary solution proposed by Mr. Meychik is faster than nested ifs
cordially
christian.stan

3 Likes

@Meychik thank you that worked perfectly (once I selected the correct output!!)

2 Likes

@christian.stan I test this solution also and worked perfectly. thank you.

1 Like