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.
my code works in the pycharm bu wont work here why
i run the same code in jupyter and it worked
dimensions = [ (5, 5), (10, 10), (2.2, 2.3), (100, 100), (8, 70), ] def area(dimensions): products= for x in dimensions: product = 1 for element in x: product *= element products.append(product) return tuple(products) #print(area(dimensions))
Steven Parker217,557 Points
I'd guess you've misinterpreted the instructions, which is easy to do when you work on challenges in an external REPL or IDE. Then it seems like it "works", but it's doing something different from the requirements.
The instructions tell you that the argument "will be a two-member tuple". Your implementation of looping through any number of elements is fancier than needed, yet could still work. But the code is also trying to loop through each individual element (loop within a loop), but since the elements are just numbers they cannot be used as iterators. You were probably thinking the function would process the entire list of sample data at once, but that's not what they are asking for.
The instructions also ask you to "return the result of multiplying the first item ... by the second item". But the code is building a list and returning it as a tuple, when all you need to return is the single product value.
Give it another shot, and I'll bet you get it this time.