Python Programming - Lambda Functions - Discussion

Discussion Forum : Lambda Functions - General Questions (Q.No. 24)
24.
How can a lambda function be used to define a key for sorting a list of tuples by the second element?
lambda x: x[1]
lambda x: x[0]
lambda x: x[2]
lambda x: x[-1]
Answer: Option
Explanation:
The lambda function lambda x: x[1] extracts the second element of a tuple, which is suitable for sorting based on the second element.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.