i have 2 lists
a=[[2,3,5],[3,6,2],[1,3,2]]
b=[4,2,1]
i want the output to be:
c=[[8,12,20],[6,12,4],[1,3,2]]
At present i am using the following code but its problem is that the computation time is very high as the number of values in my list are very large.The first list of list has 1000 list in which each list has 10000 values and the second list has 1000 values.Therefore the computation time is a problem.I want a new idea in which computation time is less.The present code is:
a=[[2,3,5],[3,6,2],[1,3,2]]
b=[4,2,1]
c=[]
s=0
for i in b:
c1=[]
t=0
s=s+1
for j in a:
t=t+1
for k in j:
if t==s:
m=i*k
c1.append(m)
c.append(c1)
print(c)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…