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 trial

Python Python Collections (2016, retired 2019) Tuples Packing

Couldn't multiply correctly

I don't see why multiplying the interating variable (nums) by it self won't return the product?

twoples.py
def multiply(*args): 
    total=0
    for num in args: 
        total=num*num
    return total

2 Answers

Steven Parker
Steven Parker
229,645 Points

Remember that the task is to return the total product "of all of the supplied arguments". But "num * num" is the square of just one of the arguments. And if you reassign total with this in a loop, then when the loop finishes total will contain the square of the last argument.

Try again, and remember that you want to multiply the arguments by each other, and retain (instead of replace) the product during the loop.

Ah! The light bulb just went off. Thank you!