Question: 6. Sort a list of tuples by the second element using Lambda. Sample input: [('Apple', 12), ('Pear', 2), ('Orange', 15), ('Banana', 0)] Output: [('Banana',

6. Sort a list of tuples by the second element using Lambda. Sample input: [('Apple', 12), ('Pear', 2),

6. Sort a list of tuples by the second element using Lambda. Sample input: [('Apple', 12), ('Pear', 2), ('Orange', 15), ('Banana', 0)] Output: [('Banana', 0), ('Pear', 2), ('Apple', 12), ('Orange', 15)] In [ ]: before = [('Apple', 12), ('Pear', 2), ('0range', 15), ('Banana', 0)] # Use lambda to create an output list: your answer here print("Original list of tuples:") print (before) print(" Sorted list of Tuples:") print (after)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The question asks for a list of tuples to be sorted by their second element using a lambda function ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!