Hello! I am stuck with the calculator part. I have followed every way I have seen to do the mean however it comes up with error and I cannot work out why;
Traceback (most recent call last):
File “C:\Users\lydia\PycharmProjects\Mean Calculator\Mean Calculator.py”, line 16, in
mean_row = np.mean(a, axis = 0).tolist()
File “<array_function internals>”, line 5, in mean
File “C:\Users\lydia\AppData\Local\Programs\Python\Python39\lib\site-packages\numpy\core\fromnumeric.py”, line 3419, in mean
return _methods._mean(a, axis=axis, dtype=dtype,
File “C:\Users\lydia\AppData\Local\Programs\Python\Python39\lib\site-packages\numpy\core_methods.py”, line 178, in _mean
ret = umr_sum(arr, axis, dtype, out, keepdims, where=where)
TypeError: cannot perform reduce with flexible type
Has anyone else found this? The mean section is my latest attempt, I swear I’ve tried every tutorial I’ve seen. This is all of my code so far;
import numpy as np
n = ()
while len(n) != 9:
n = list(input("Enter 9 numbers (no spaces): "))
if len(n) != 9:
print("Must be 9 numbers")
else:
break;
n_array = np.array(n)
print(n_array)
a = np.array(n).reshape(3, 3)
print(a)
mean_row = np.mean(a, axis = 0).tolist()
print(mean_row)
P.S not sure why the indents have vanished when I posted on here, but they are there in real life