List methods and copies
Lists change in place. These methods modify the list and return None, except pop, which returns what it removed.
xs = [3, 1]
xs.append(4) # [3, 1, 4]
xs.extend([1, 5]) # [3, 1, 4, 1, 5]
xs.insert(0, 9) # [9, 3, 1, 4, 1, 5]
xs.remove(1) # first 1 only
last = xs.pop() # takes the 5
print(xs, last) # [9, 3, 4, 1] 5
print(xs.index(4), xs.count(1)) # 2 1remove and index raise ValueError when the value is not there, so check with in first. pop(0) takes from the front.
Copies
b = a gives the same list a second name. a.copy(), list(a) and a[:] make a new outer list:
a = [[1, 2], [3]]
b = a.copy()
b.append([4])
b[0].append(99)
print(a) # [[1, 2, 99], [3]]The copy is shallow: it holds the same inner lists. copy.deepcopy copies all the way down. [[0] * 3] * 3 has the same trap, three references to one row.
Your task
Write move_to_front(items, value) returning a new list with the first occurrence of value moved to the front, leaving items unchanged (a plain copy if value is missing). Write make_grid(rows, cols) returning rows separate lists of cols zeros.
The explanation opens here once every check passes.