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 trialAron Tseggai
3,204 PointsThe error says 'Couldn't find multiply' I just get this error using *args as an argument in the function.
I would really love better errors when doing these assignments.
def multiply(*args):
list = []
for num in args:
list.append(int(num))
return reduce(lambda x, y: x * y, list, 1)
1 Answer
Steven Parker
231,269 PointsI see four issues:
- "
from functools import reduce
" - the arguments aren't necessarily integers, converting them could produce incorrect results
- "list" is the name of a built-in, so not a good choice for a variable name
- "list" is not needed since "args" can be passed directly to reduce
And you can omit the initializer since multiplying with 1 is an identity operation.
Aron Tseggai
3,204 PointsAron Tseggai
3,204 PointsThank you for your feedback.