Great job Larz60+. In post #10 Larz60+ output was:
Output:list0 = a[0]*b[0] + a[0]*b[1] + a[0]*b[2] + a[0]*b[3] = 10
list1 = a[1]*b[0] + a[1]*b[1] + a[1]*b[2] + a[1]*b[3] = 490
list2 = a[2]*b[0] + a[2]*b[1] + a[2]*b[2] + a[2]*b[3] = 1210
list3 = a[3]*b[0] + a[3]*b[1] + a[3]*b[2] + a[3]*b[3] = 2330
list4 = a[4]*b[0] + a[4]*b[1] + a[4]*b[2] + a[4]*b[3] = 3320
list5 = a[5]*b[0] + a[5]*b[1] + a[5]*b[2] + a[5]*b[3] = 2370
list6 = a[6]*b[0] + a[6]*b[1] + a[6]*b[2] + a[6]*b[3] = 1190
I believe the output should be (changed the a indices in output - calculations are identical):Output:list0 = a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3] = 10
list1 = a[1]*b[0] + a[2]*b[1] + a[3]*b[2] + a[4]*b[3] = 490
list2 = a[2]*b[0] + a[3]*b[1] + a[4]*b[2] + a[5]*b[3] = 1210
list3 = a[3]*b[0] + a[4]*b[1] + a[5]*b[2] + a[6]*b[3] = 2330
list4 = a[4]*b[0] + a[5]*b[1] + a[6]*b[2] + a[7]*b[3] = 3320
list5 = a[5]*b[0] + a[6]*b[1] + a[7]*b[2] + a[8]*b[3] = 2370
list6 = a[6]*b[0] + a[7]*b[1] + a[8]*b[2] + a[9]*b[3] = 1190
Small change in the source code - .format(a_idx [color=#E74C3C]+ b_idx[/color][b][/b], b_idx) was .format(a_idx, b_idx)
list_a = [-1, 2, -2, 3, 41, 38, 22, 10, -1, 3] list_b = [40, 30, 20, 10] e_len = len(list_a) - len(list_b) + 1 for a_idx in range(e_len): elist = [] b_idx = 0 for bval in list_b: if b_idx == 0: print('list{} = '.format(a_idx), end='') else: print(' + ', end='') print('a[{}]*b[{}]'.format(a_idx + b_idx, b_idx), end='') elist.append(list_a[a_idx + b_idx]*bval) b_idx += 1 print(' = {}'.format(sum(elist)))Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00