Question 3
Back to Exercise
What is the output of the following Python program?
a = [3, 1, 2]
b = a.sort()
c = sorted(a, reverse=True)
print(a, b, c)
- A [3, 1, 2] [1, 2, 3] [3, 2, 1]
- B [1, 2, 3] [1, 2, 3] [3, 2, 1]
- C [1, 2, 3] None None
- D [1, 2, 3] None [3, 2, 1] Correct
Correct Answer: Option D
sort() changes a and returns None; sorted() returns a new list.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!