# Adding values within a list and create a new list

here we go,
list : 2,2,2,2,2

the output should be like this logic:
new list :
first item stays same: 2
second item: first item + second item = 2+2 = 4
third item : first + second + third = 2+2+2 =6 and so on.

final output: 2,4,6,8,10

any idea guys?

this list should be appropriate to attack:
input:
list: 1500,800,2500,1100,3500,1400,4500,1700
ouput: 1500,(1500+800), (1500+800+2500)â€¦and so on

You could try the simple solution outlined here:

Hereâ€™s a screenshot as applied to your example list.

5 Likes

Effective. thanks for the solution.
I have a question. What does the DSCore in the recursive node do? i mean you have written , 1â€¦DSCore.List.Count(a)

It is necessary if one have a package installed that also have a list.count function etc. this specifies that it is the build in method that is required.
These two are the same:

3 Likes

It just accesses the Count function from the Design Script core used by Dynamo. You donâ€™t need to worry about it
As you can see from my screenshot, you donâ€™t even have to write it for the count function to work.
Please mark the solution as solved.

yeah, i tried without DSCore and it worked before seeing the replies of its usage. Cool idea. ll mark it.

Thanks for the info. thatâ€™s an insight into the dynamo to know something existsâ€¦

Iâ€™ll take the liberty of moving the solution mark to the comment showing the solution provided by @sed07

1 Like

by the way, whatâ€™s the advantage of getting oneâ€™s comment, marked as solution. I am new to forum for posting questions, though i frequently seek help from the threads.

The advantage is that the solution will be moved to the top of the thread and that way people searching information does not have to scroll though a long thread if only the solution is indeed required For someone there is no â€śadvantageâ€ť except from the acknowledgement of having provided a work-able solution

1 Like

thats nice to know. â€śServiceâ€ť and knowledge sharingâ€¦ thanks for the help guysâ€¦ i will try to help as well.

1 Like