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

srikanth soma
srikanth soma
1,572 Points

Tuples

def multiply(*args):
    for item in args:
        result = item * args
        return result
twoples.py
def multiply(*args):
    for item in args:
        result = item * args
        return result

2 Answers

srikanth soma
srikanth soma
1,572 Points

Yes, It helps thanks

AJ Salmon
AJ Salmon
5,675 Points

Happy to hear! No problem.

AJ Salmon
AJ Salmon
5,675 Points

You're not supposed to multiply every item in the argument by the argument, but multiply all of the items together. You need to create a variable equal to 1 before the for loop, so that the items have something to start with. Then you can multiply each item by that variable, and each time change the variable into the product of the item and the variable with *=. then just return the variable! (I named my variable total) Hope this helps!!

def multiply(*args):
#create a variable equal to 1 
    total = 1
    for item in args:
# the *= opperand multiplies the two values and then assigns the product to the variable
        total *= item
    return total