$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #34

What is the correct fix?

nums = [3, 1, 2]
sorted_nums = nums.sort()
print(sorted_nums)
  1. Use sorted_nums = sorted(nums)
  2. Change sort() to sort(reverse=True)
  3. Print nums.sort() directly
  4. Use nums.sorted()
list.sort() returns None; sorted() returns a new list.
Play Problem Solving ▸