Question of get_top_covariances function in C2W2 assignment

I read a topic about the similar question but still cannot figure out how to write the code in this function. At the beginning I faced some assertion errors. I managed to adjust the code to fulfill the test unit. Although the running test passed, but I still suspect that it might just be a coincidence. Here is what I wrote:

covariance_matrix = covariance_matrix_from_examples(classification_changes)
# print(covariance_matrix.shape)
# print(covariance_matrix)
top_magnitude_indices = get_top_magnitude_indices(covariance_matrix[target_index])
# print(top_magnitude_indices.shape)
# print(top_magnitude_indices)
relevant_indices = top_magnitude_indices[1:top_n + 1]
# print(relevant_indices)
highest_covariances = covariance_matrix[target_index][relevant_indices]
# print(highest_covariances.shape)
# print(highest_covariances)

The other lines seem plausible to me , but the line of relevant_indices seems to be wrong. I do not know why [1:top_n+1] is used here as well but it just makes the program works. I do not know where and how to use the function remove_from_list so I just leave it there without use.

Please solve my question and thank you.

@Zhefei_Meng, have you figured this out?
A couple of hints: remove_from_list should be helpful in removing the target feature
Once you’ve adjusted top_magnitude_indices to remove the target index, re-think what makes sense for relevant_indices.

Yes, with your hint now I could understand how to get to the answer with the correct coding. It was just the top_magnitude_indices and which element should be removed that confused me a lot. I thought the remove_from_list function would remove the element at the corresponding position to the second parameter rather than the corresponding value by mistake. The next step is to remove the element in the position of target_index from top_magnitude_indices.

Thank you.