Complete the code to split the list into two halves.
mid = len(arr) [1] 2
We use integer division (//) to find the middle index so that it is an integer.
Complete the code to recursively sort the left half of the list.
left_sorted = merge_sort(arr[1]:mid)We use square brackets [] to slice the list from start to mid.
Fix the error in the merge step to compare elements correctly.
if left[i] [1] right[j]:
We compare if left[i] is less than right[j] to merge in sorted order.
Fill both blanks to complete the loop that merges remaining elements.
while i [1] len(left): result.append(left[2]) i += 1
The loop runs while i is less than the length of left, and we append left[i].
Fill all three blanks to complete the merge function's return statement.
return result + left[1] + right[2] if i [3] len(left) else result + right[j:]
We add the remaining elements from left[i:] and right[j:] if i is less than len(left), else result + right[j:].
