← Quiz: itertools and functools: all 10 questions
Quiz: itertools and functools · Question 10 of 10
What does cmptokey let you do?
What does cmp_to_key let you do?
- A.Compare two dictionaries
- B.Turn a key function into a comparison
- C.Sort with a function that compares two items and returns negative, zero or positive
- D.Sort without using any key
Answer & explanation
Correct answer: Sort with a function that compares two items and returns negative, zero or positive
It adapts a two-argument comparison for use as key= in sorted().
Can you get the rest right without peeking?
Take the timed Quiz: itertools and functools quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →