Create list from If else statement using code block


Hi all, I have two kinds of list for coordination, for instance there is two types of list for x =[a,b,c,d] z=[e,f,g,h] and x=[a1,b1,c1,d1] z=[e1,f1,g1,h1], and a varible p=, I want if p>4, and i will get x =[a,b,c,d] z=[e,f,g,h], else x=[a1,b1,c1,d1] z=[e1,f1,g1,h1], unfortunately I cant make it work, can anyone help me?
Many Thanks

Dynamo 1.3 or Dynamo 2.x?

Dynamo 2.x

Hi,

Oh! I see!! But what if I wanted it in a single node?it is there anything wrong with the code?
many thanks

xt= ["a","b","c","d"];
zt=["e,"f","g","h"];
xf=["a1","b1","c1","d1"];
zf=["e1","f1","g1","h1"];

x = p>4?xt=[]:xf=[];
z = p>4?zt=[]:zf=[];

Try this instead :slight_smile:

xt= ["a","b","c","d"];
zt=["e","f","g","h"];
xf=["a1","b1","c1","d1"];
zf=["e1","f1","g1","h1"];

x = p>4?xt:xf;
z = p>4?zt:zf;

Or this :

x = p>4?["a","b","c","d"]:["a1","b1","c1","d1"];
z = p>4?["e","f","g","h"]:["e1","f1","g1","h1"];

Thx!!You made my day!!

Glad I helped :slight_smile:

1 Like