🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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]))
  1. A.[('b', 2), ('a', 3)]
  2. B.[('a', 3), ('b', 2)]
  3. C.[2, 3]
  4. 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 →