0
trying to get numpy row averages from inputs, what am I doing wrong?
I'm struggling with https://www.sololearn.com/learning/eom-project/1093/111 my code: import numpy as np n , p = [int(x) for x in input().split()] arr2D = list(range(n)) for i in range(n): arr2D[i] = [round(float(x),2) for x in input().split()] nparr= np.array(arr2D) print(nparr.mean(axis=1)) this seems to work for the first 3 test cases, but fails at the last 2. As split() creates a list in the list[i], so I don't think I 'p' is needed. Where am I going wrong?
2 Réponses
+ 2
Why do you round inside the loop? Wouldn't it suffice to round the output?
0
never mind.
I was rounding the wrong numbers, I'm an idiot