Hi,
I am trying to check if an item in list 1 is present in list 2 and return a list of values based on items in list 3.
Example:
List1: [zero, two, three, four, five, seven]
List2: [one, zero, five, three, six]
List3: [0,1,4,7,9]
The returned list should be: [1,0,7,0,4,0]
My code is listed below, but my returned list is wrong. Can anyone find my error?
Update: I have changed the code to simplify it, but I still don’t end up with a useful result:
I think this might be a bug with the ternary operator inside imperative code:
try an if statement.
@tmdA5HML You can achieve that in Python as shown below:
List1=IN[0]
List2=IN[1]
List3= IN[2]
OUT=[]
for item1 in List1:
if item1 in List2:
ind=List2.index(item1)
OUT.append(List3[ind])
else:
OUT.append(0)
1 Like
kennyb6
4
In if statement codeblock form:
t1 = List.IndexOf(y,x);
t1==-1?0:List.GetItemAtIndex(z,t1);
2 Likes
Thanks @salvatoredragotta ! This worked perfectly.
I tried an if statement earlier with the same result, but using Python worked. It seemed the for loop was the problem.
Thanks for your help, though!
@tmdA5HML please mark the post as solved