Standard deviation - float not iterable


Review Exercise

If I use the following code:

def grades_std_deviation(variance):
result = variance ** 0.5
return result

...taking the variance as an input, then the standard deviation function behaves fine. But if I try to make the standard deviation function take an input of grades like all the other functions in the exercise:

def grades_std_deviation(grades):
result = grades_variance(grades) ** 0.5
return result tells me a float is not iterable. I don't understand what I'm iterating here, or how this function is different than the variance function or average function, which both take inputs of grades and call a previously defined function.

I suppose whatever the reason is why they designed the exercise to just take variance as an input, but I'd like to better understand the reasoning and the problem.

I hoped it would work.

Replace this line with your code.


You're treating a float as if it was a list or other iterable, likely you're either operating on the wrong value or trying to do something with a value that you should not. You'll need to reproduce the crash and find out where it occurs so that you can look closer in that part of your code and determine which is the case.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.