Hi everyone,
It seems to me that I’m missing some small detail. I’ve compared my code output in VScode with the tests results and they are the same. Despite this, I’m getting the following type error:
unsupported operand type(s) for -: ‘dict’ and ‘dict’
So, could someone tell me what this problem means and how to solve it?
import numpy as np
def calculate(list):
if len(list) != 9:
raise ValueError ("List must contain nine numbers.")
arr = np.array(list)
arr_2d = arr.reshape(3, 3)
calculations = {"mean": [np.mean(arr_2d, 0).tolist(), np.mean(arr_2d, 1).tolist(), np.mean(arr_2d)]}
calculations["variance"] = [np.var(arr_2d, 0).tolist(), np.var(arr_2d, 1).tolist(), np.var(arr_2d)]
calculations["standart deviation"] = [np.std(arr_2d, 0).tolist(), np.std(arr_2d, 1).tolist(), np.std(arr_2d)]
calculations["max"] = [np.amax(arr_2d, 0).tolist(), np.amax(arr_2d, 1).tolist(), np.amax(arr_2d)]
calculations["min"] = [np.amin(arr_2d, 0).tolist(), np.amin(arr_2d, 1).tolist(), np.amin(arr_2d)]
calculations["sum"] = [np.sum(arr_2d, 0).tolist(), np.sum(arr_2d, 1).tolist(), np.sum(arr_2d)]
return calculations
Here is
link to my code
Thanks for your attention!