I am trying to sum from 4 lists there elements with each other. For a example the first element from fours lists, then the second element etc
But instead of that i am getting a list with nested lists with the four elements and i cannot understand why and how to solve it.Any ideas?
#dependency influence calculation
def dep_Influence(a,b,c,d,decimal):
influence=[]
for i in range(len(a)):
x=float(a[i]) 0,5*float(b[i]) 0,33*float(c[i]) 0,25*float(d[i])
influence.append(x)
influence = np.around(influence,decimal)
return influence
CodePudding user response:
When multiplying by float numbers, use points instead of commas to represent those values:
def dep_Influence(a,b,c,d,decimal):
influence=[]
for i in range(len(a)):
x=float(a[i]) 0.5*float(b[i]) 0.33*float(c[i]) 0.25*float(d[i])
influence.append(x)
influence = np.around(influence,decimal)
return influence
print(dep_Influence([1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], 2))
[2.08 4.16 6.24]