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), ('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
The question asks for a list of tuples to be sorted by their second element using a lambda function ... View full answer
Get step-by-step solutions from verified subject matter experts
