Three List Combinations

I am so amateur on Dynamo.
I am trying to built such a logical process.
If you help me I will be so happy.

List 1
1,1,1,1,2,2,2,3,4,4,4,5;
List 2
1,2,3,4,5;
List 3
“a”,“b”,“c”,“d”,“e”;
If List1 item = List 2 item then List1 item will be replaced with List 3 item
The Result list will be like that
a,a,a,a,b,b,b,c,d,d,d,e;

Hi @vahapunlu,

The easiest way is to build a dictionary :

4 Likes

Or a python version :slight_smile:

keys = IN[0]
vals = IN[1]
val_at_key = IN[2]
# create a dictionary from keys (integers in this case) and values (letters) using zip()
d = dict(zip(keys, vals))
OUT = []
# itereate the new keys list you want to obtain the corresponding values from, 
#and use the dictionary get() method to get the value 
for i in val_at_key:
	OUT.append(d.get(i))
4 Likes

Here below another python solution if you don’t like dealing with dictionary :slight_smile:

2 Likes


Thank You for your advice.
I use it for my first Dynamo work.
It imports some date (Activity Start,Finish and Today Date, Revit Category) from excel.I assign the data to the model element’s shared parameters for Construction Schedule work.

Thank you for your advice.
I have no experience in Pyton. It looks great to do something with Python much more easier.
I will try it.

Thank you for your advice.
I will try it.