python - "Float object is not iterable"? -
I have written a function to find the standard deviation of a list: def Average (L): Return amount (L) / Lane (L) DEF STDDev (L): For category (Lane (L) -1): Return sqrt ((zodiac (l [i] - AGG (L)) ) ** 2) / lane (l) If I run it and input the shell [20,10,30] it says, "float object is not variable ". Where is the problem, and can I resolve the integer results of any of these tasks without settling the results? sum (l [i] -avg (L)) - here You have the amount of a float. You also have the return statement for each pass of the loop, which is clearly wrong. The formula for standard deviation is also not correct, because you have lost the braces I believe that you want: better than the elements in their index: for L in X: s + = (x - avg (L)) ** 2 or def stdDev (L): ave = avg (l) s = sum ((x - avay) ** in l ) Return sqrt (s / len (L))