Python Script Works in compiler but does not work in dynamo

Hello Everybody ,

I have a problem with python scpripting in dynamo. My script works in online interpreter correctly but in dynamo there is no output or error. It says empty for OUT variable. I checked list1 and list2 . I ve tried to add only list1 or list2 to the OUT variable and it happened. I have tried the all script and it gave me empty OUT variable. I couldn’t understand the problem. Thanks for helping.

list1=[1,3,5,4,2]
list2=[[5,"db"],[2,"cfk"],[3,"vnvod"],[1,"nrı"],[4,"fmro"]]
result=[]
for j in list1:
  for i in range(len(list2)) :
    if j==list2[i][0]:
        result.append(list2[i][1])
        
        
OUT=result 
print(OUT)

I think you could try brackets and not parenthesis.

Also, are you comparing similar data types? Are both List1 and List2 strings for instance? If they aren’t it won’t match, but will run.

This is the list of list in dynamo. I have corrected it. I ve just use it in compiler as a tuple.

list1 is integer list2 is integer and strings list1=[integer] , list2=[[integer,string]]. Here I am matching the integer parts. If that is the problem ,then i should divide the list2 as two different lists and then compare integer parts. Is that right?

Edit:
This worked fine for me.

image

You are right. The problem was about the data. I was getting the data from an excel sheet for list2 and it was general type in excel. So i have changed the both list1 and list2 to string type after reading data and it worked fine for me too. Thank you for your help.

1 Like