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)))
To apply the lambda function to each element of an iterable
To filter elements from an iterable based on the lambda function's condition
To create a sorted list based on the lambda function's values
To create a list of products of each element and its index in the iterable
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:

Your comments will be displayed after verification.