Python Programming - Lambda Functions - Discussion
Discussion Forum : Lambda Functions - General Questions (Q.No. 17)
17.
What is the purpose of the following code using the
enumerate()
function and a lambda function?
my_list = [1, 2, 3, 4, 5]
result = list(map(lambda x: x[0] * x[1], enumerate(my_list)))
Answer: Option
Explanation:
The code uses
enumerate()
to get tuples of index and element, and the lambda function multiplies the index (x[0]
) by the element (x[1]
).
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers