I have a list L. I want to average elements of each list within this list. But I am getting an error. I present the expected output.
L=[[], [1.3342713788981633], [1.3342713788981633], [0.40896852187708455,1,3]]
L_avg=[(i+j)/len[i,j] for [i,j] in L]
print(L_avg)
The error is
in <listcomp>
L_avg=[(i+j)/len[i,j] for [i,j] in L]
ValueError: not enough values to unpack (expected 2, got 0)
The expected output is
L_avg=[[], [1.3342713788981633], [1.3342713788981633], [(0.40896852187708455+1+3)/3]]