Sum only Corresponding Member

Hello friend again. I confused by Sum two sample list. I want to only corresponding member be added to each other. You can see the pic. But i cant do that. Do you have solution for that?


@f.saeedian

you will need some kind of zip function

lis1 = IN[0]
lis2 = IN[1]

lis3 = []
for sublist1, sublist2 in zip(lis1, lis2):
    for i, val2 in enumerate(sublist2):
        lis3.append([val2 + val1 for val1 in sublist1])

OUT= lis3
2 Likes

thats great and work , but I want to use that for determine point distance, can you help me how I can do that by python script?

Hi,
You add

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

Geometry.DistanceTo(val1,val2)

Cordially
Christian.stan

2 Likes

thanx alot Mr. @christian.stan that is true ,

2 Likes

thank you for the compliment, all the credit goes to Mr. Andreas, a natural hard worker (also a beer on the terrace from time to time, the good Dynamo spirit) the training provided by Mr. Erick Frits seems to have made him progress a lot Also no subliminal message
Sincerely
christian.stan

2 Likes

@christian.stan

thats true Erik Fritz is my mentor. :smile: it boosted my understanding how code works in the field.

:raised_hands:

3 Likes

I see this was already solved here. nevertheless it was a nice little problem for me to work on. while Iā€™m here I wonder if anyone has some sort of workbook to practice python on dynamo and revit problems like this. I have started my python journey and it would be great to work on some practice problems. Any guides. :innocent:

1 Like

@rajeshjamariya16

Learning advice - Dynamo

and this community here

3 Likes

Great resources! Thank you!

1 Like