Contact: aviboots(AT)netvision.net.il
39,936 questions
51,873 answers
573 users
import numpy as np list1 = [[1, 2, 3], [4, 5, 6]] list2 = [[9, 0, 5], [8, 7, 1]] multiply = np.multiply(list1,list2) print(multiply) ''' run: [[ 9 0 15] [32 35 6]] '''
list1 = [[1, 2, 3], [4, 5, 6]] list2 = [[9, 0, 5], [8, 7, 1]] multiply = [[0] * 3] * 2 for i in range(len(list1)): multiply[i] = [x * y for x, y in zip(list1[i], list2[i])] print(multiply) ''' run: [[9, 0, 15], [32, 35, 6]] '''
list1 = [[1, 2, 3], [4, 5, 6]] list2 = [[9, 0, 5], [8, 7, 1]] multiply = [[0] * 3] * 2 for i in range(len(list1)): multiply[i] = list(map(lambda x, y: x * y ,list1[i], list2[i])) print(multiply) ''' run: [[9, 0, 15], [32, 35, 6]] '''