← Quiz: Comprehensions and Lambda: all 15 questions
Quiz: Comprehensions and Lambda · Question 10 of 15
What does this print? (code)
What does this print?
print(sorted([("b", 2), ("a", 3)], key=lambda t: t[1]))
- A.[('b', 2), ('a', 3)]
- B.[('a', 3), ('b', 2)]
- C.[2, 3]
- D.An error
Answer & explanation
Correct answer: [('b', 2), ('a', 3)]
Sorted by the second item: 2 then 3.
Can you get the rest right without peeking?
Take the timed Quiz: Comprehensions and Lambda quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →