Answer the question
In order to leave comments, you need to log in
Why is no one using map?
Why do this:
a = [5, 10, 20, 40, 80]
j = [i**2/5 for i in a]
j = list(map(lambda x: x**2/5, a))
Answer the question
In order to leave comments, you need to log in
At a minimum, the variant with for is clearer and more readable.
From the point of view of performance, in both cases O (n), the map function does not do any "magic", the same loop runs inside.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question