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 trialsrikanth soma
1,572 PointsTuples
def multiply(*args):
for item in args:
result = item * args
return result
def multiply(*args):
for item in args:
result = item * args
return result
2 Answers
srikanth soma
1,572 PointsYes, It helps thanks
AJ Salmon
5,675 PointsYou'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
AJ Salmon
5,675 PointsAJ Salmon
5,675 PointsHappy to hear! No problem.