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

Idan shami
Idan shami
13,251 Points

packing challenge, I don't understand what I need to do in this challenge

I literally don't know what to do in this packing challenges, what the challenge asking from me to do?? I'm so frustrated, feel like I can't complete the challenges... please help.

twoples.py
def multiply(*args):
    for value in args:

2 Answers

Steven Parker
Steven Parker
231,275 Points

Since you used args as a loop iterator, I'll assume you understand how the unpacking (AKA "splat") operator works. So what the challenge wants you to do is multiply all the arguments with each other.

So if someone called "multiply(3, 4, 5)" what the function would do is calculate 3 * 4 * 5 and return the result 60 back to the caller. You just need to program this so it will handle any number of arguments.

Idan shami
Idan shami
13,251 Points

ok, did it like this:

multiply(num1, *args):
    total = num1
    for num in args:
        total *= num
    return total

sometimes I get frustrated with easy things like that...

Steven Parker
Steven Parker
231,275 Points

Good job! :+1: (I'm sure the version that passed the challenge had a "def" in front).

Happy coding!

you forgot def in the begging of line 1