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 Functional Python Functional Workhorses Map Comprehension

SUVODEEP DUBEY
SUVODEEP DUBEY
2,470 Points

Map Comprehension Error In Code Challenge

Please find the code below I am getting expected result in my Notebook but in the console I am getting Error that 'int' is not subscriptable

maps.py
dimensions = [
    (5, 5),
    (10, 10),
    (2.2, 2.3),
    (100, 100),
    (8, 70),
]

def area(dim):
    return list(map(lambda x: x[0]*x[1], dim))

a = area(dimensions)

2 Answers

Steven Parker
Steven Parker
231,271 Points

You've written a function that does something different from what the instructions asked for. Take another look at the instructions for task 1:

"Create a function named area() that takes a single argument which will be a two-member tuple. area() should return the result of multiplying the first item in the tuple by the second item in the tuple."

Note that the function should take a single tuple argument instead of a list of them, and return a numeric value instead of a list. The provided "dimensions" list won't be used until task 2, and with a comprehension instead of a "map".

SUVODEEP DUBEY
SUVODEEP DUBEY
2,470 Points

Thanks Steven I got the point