B = [[1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]]
i_max, j_max = len(A), len(A[0])
C = []
for i, line_b in enumerate(B):
    line_c = [A[i % i_max][j % j_max] for j, _ in enumerate(line_b)]
C.append(line_c)
print(C)
Resize matrix by repeating copies of it, in python