Error with Mean-Variance-standard deviation calculator

Hello, apologies if I mess up the format on the forum- my first time posting.

I’m getting an ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() when I try to run the Mean-Variance-STD calculator project.

My code seems to work for the test in, just not the test module. My guess is that something is going wrong in the comparison between my output code and the expected answer in Numpy was updated to a new version a few days ago if I understand correctly- I’m a little bit suspicious it’s something to do with that, though that could be way off.

Thank you for the help!

1 Like

Take a closer look at the example output and output of your code. In the example each value consist two lists and number from the flattened calculation, while in your function values consist two np arrays and number.


Ah it even points that out in the instructions! Ah silly me, thank you!

Thanks for posting this - it was a nasty sting in the tail.
Maybe things will be OK when the “interactive instructional part” is ready but right now, it’s a little tough as a first assignment for people with no experience, surely?
The trick, as you can see from the OP’s code, is to add .tolist() after each variable that needs it in the dictionary at the end.