← Quiz: Python Lists: all 15 questions
Quiz: Python Lists · Question 15 of 15
What does this print? (code)
What does this print?
nums = [5, 2, 8]
nums.sort(reverse=True)
print(nums)
- A.[2, 5, 8]
- B.None
- C.[5, 2, 8]
- D.[8, 5, 2]
Answer & explanation
Correct answer: [8, 5, 2]
sort(reverse=True) sorts the list in place from largest to smallest.
Can you get the rest right without peeking?
Take the timed Quiz: Python Lists quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →