Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJustin White
4,545 PointsTuples multiply(*args)
I am really having a hard time with this one. Can someone point me in the right direction?
Thank you!
def multiply(*args):
product = 0
for num in args:
product = product * num
return product
1 Answer
Steven Parker
231,236 PointsAnything multiplied by 0 is 0.
So if you start with 0, no matter how many things you multiply with it, you'll still have 0.
On the other hand, if you start with 1, the first time you multiply you will get the value it was multiplied with. Then the product continues to increase with each other multiplier, exactly as the challenge expects.
Justin White
4,545 PointsThank you. I don't know what is wrong with my brain today. It just went over my head a little.
Justin White
4,545 PointsJustin White
4,545 PointsI found that it works if I change product to 1 instead of 0. However, I still don't understand what this is doing here. Can someone explain to me what this code is actually doing?
Thank you