Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
220,416 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
220,416 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