# Finding the product of a list of numbers

**URL:** <https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615>\
**Category:** Uncategorized\
**Created:** [December 12, 2018, 2:23pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615 "2018-12-12T14:23:08Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [December 12, 2018, 2:23pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/1 "2018-12-12T14:23:08Z")

</div>

I’m trying to find the product of a list of numbers.

…

That’s all!

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [December 12, 2018, 2:25pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/2 "2018-12-12T14:25:17Z")

</div>

What have you tried so far? Please show some effort.

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [December 12, 2018, 2:30pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/3 "2018-12-12T14:30:27Z")

</div>

Just trying out some python which I don’t really understand, neither loops in Dynamo code.

I don’t see the point in sharing non-functioning Dynamo graphs or python scripts.

---

<div class="post-metadata">

**Author:** ![mellouze](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mellouze](https://forum.dynamobim.com/u/mellouze)\
**Post date:** [December 12, 2018, 2:31pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/4 "2018-12-12T14:31:49Z")

</div>

Hope this helps 🙂

![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/8/1832952f297de440557cfc6be3221433bfaa5a51.png)

Note : A funny way to do it would be to compute the log() of every item, sum this logs, then apply exp() to the sum 😛

Note : The python way to do it 🙂

```
liste = IN[0]
result = 1
for i in liste:
	result = result * i
OUT = result
```

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [December 12, 2018, 2:35pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/5 "2018-12-12T14:35:50Z")

</div>

> [@PauLtus](#):
>
> I don’t see the point in sharing non-functioning Dynamo graphs or python scripts.

The point is to show the work you’ve done so far so that a) we can help explain why something might not be working and b) so we’re not just doing your work for you.

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [December 12, 2018, 2:36pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/6 "2018-12-12T14:36:34Z")

</div>

Works as it should.  
Thanks a lot!  
I should really learn how to use loops in the Dynamo scripts…

---

<div class="post-metadata">

**Author:** ![mellouze](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mellouze](https://forum.dynamobim.com/u/mellouze)\
**Post date:** [December 12, 2018, 2:37pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/7 "2018-12-12T14:37:23Z")

</div>

> [@PauLtus](#):
>
> loops in the Dynamo scripts…

I highly recommend avoiding loops in Dynamo outside Python 🙂

Edit : The only case that oblige you to work with loops in Design Script is when you have a result that depend on the value of every item of your list (which is the cas here) AND when you have to use a Custom Node (or at least a function not callable in Python) (which is not the case here)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [December 12, 2018, 2:41pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/8 "2018-12-12T14:41:18Z")

</div>

I agree with @mellouze. Dynamo doesn’t really support “loops” in the way that most people are familiar with. It’s best not to think in terms of looping through data in the Dynamo environment. Python, however, is great for loops.

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [December 12, 2018, 2:47pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/9 "2018-12-12T14:47:02Z")

</div>

I understand the annoyance with someone just putting out an “make this for me” but please don’t confuse the simplicity of my original comment with laziness. This is a very “singular” step to take so there’s not much to show that can be improved.

Annoyingly I just haven’t really managed to wrap my head around how to handle loops (aside from using while loops in C several years ago).

So while typing this I saw you and @mellouze comment that creating a loop in Dynamo is a bit of a pain so I guess I’ll invest time in learning it in Python in which case I’m still having trouble actually getting the result of the loop out of the Python node (at least, I think that’s the problem).

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [December 12, 2018, 2:51pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/10 "2018-12-12T14:51:30Z")

</div>

I know you’re not just asking for us to do it for you. You know better than that. 😁  
I was more concerned with seeing whether you were trying python or design script and what kind of looping you were attempting. It was a very “basic” question so I was just trying to discern what your specific issue was.

And for what it’s worth, I prefer python over design script for anything involving loops. A simple loop like this is basically the same in either syntax but (I think) the formatting is way easier in python.

```
dataEnteringNode = IN
nums = IN[0]
product = 1

for num in nums:
	product = product * num

OUT = product
```

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [December 12, 2018, 3:09pm UTC](https://forum.dynamobim.com/t/finding-the-product-of-a-list-of-numbers/29615/11 "2018-12-12T15:09:22Z")

</div>

That looks easy enough.
