Tell us what’s happening:
How can I solve this Error? :
IndexError: too many indices for array: array is 1-dimensional, but 3 were indexed
Your code so far
import numpy as np
raise ValueError("List not contain nine numbers.")
ls = np.array(list)
mean_rows = [ls[(0,1,2)].mean(), ls[(3,4,5)].mean(), ls[(6,7,8)].mean()]
mean_columns = [ls[(0,3,6)].mean(), ls[(1,4,7)].mean(), ls[(2,5,8)].mean()]
Your browser information:
User Agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36
Challenge: Mean-Variance-Standard Deviation Calculator
Link to the challenge:
Do you have a question?
If so, please edit your post to include it in the Tell us what’s happening section.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more information you give us, the more likely we are to be able to help.
I assume by looking at the line the error is pointing at and fixing the problem?
Although the following looks weird:
So yeah, you are telling the list to grab the entry on index (0,1,2) - which is a tuple and thus a 3D coordinate. Hence it fails.
Also please look into the task and Numpy again.
By making an actual Matrix, you can utilize the
.mean() with additional arguments to get the desired result.
Thak you very much! You are right it’s a tupla, I didn’t notice.