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

Jennifer Lithgow
Jennifer Lithgow
11,778 Points

Tuples Packing Code Challenge

I'm getting an error that says "couldn't multiply valid values together," but when I copy/paste my code into IDLE and run it there, it seems to work. I don't know what the problem is. . .

twoples.py
def multiply(*args):
    to_multiply = []
    for x in args:
        to_multiply.append(x)
    product = to_multiply[0]
    count = 1
    while count <= len(to_multiply):
        product = product * count
        count += 1
    return product

3 Answers

Steven Parker
Steven Parker
229,744 Points

Did you really intend to multiply the product by the count?

I'm guessing you would rather multiply by one of the values you put into your to_multiply array.

Also check your loop to make sure you're running the correct number of times.


Now just a suggestion (it's not necessary to pass the challenge), you could multiply at the same time as you unpack so you would only need one loop (and no local array).

Jennifer Lithgow
Jennifer Lithgow
11,778 Points

Thank you so much! I corrected those things and it worked. :)

Ioannis Papaioannou
Ioannis Papaioannou
2,967 Points

Hi guys, my Python level it's "I'm trying to understand what to change here after Steven's suggestions." Could you give me more hints ? Thanks.

Steven Parker
Steven Parker
229,744 Points

Jennifer's approach is rather unique, as are my suggestions to her. Your own solution is most likely to be quite different and you will probably not encounter the same issues.

Ioannis Papaioannou
Ioannis Papaioannou
2,967 Points

Thank you, I solved it and it was very much easier than I thought. I 'll try with slices as well.