Fill the blank
Fill the blank to attach whatever is left.
a, b, out = [1, 4, 9], [2, 3], []
i = j = 0
while i < len(a) and j < len(b):
if a[i] <= b[j]:
out.append(a[i])
i += 1
else:
out.append(b[j])
j += 1
out += ____
print(out)Choose an answer, then open Show answer below to check it.
Show answer
Answer: A a[i:] + b[j:]
Right: one of the two slices is empty, and the other holds the sorted leftovers.
On a chain the same step is a single arrow, because the leftover part is already linked in order.
Why not the others?
- B a + b. That repeats values already taken.
- C sorted(a + b). It re-sorts everything and repeats values.