I know why this error arises, but don't know how to get around it. This is my code followed by the error message:
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def print_grades(grades): for grade in grades: print grade def grades_sum(grades): total = 0 for x in grades: total += x return total def grades_average(grades): sum_of_grades = grades_sum(grades) average = sum_of_grades / float(len(grades)) return average def grades_variance(scores): variance = 0 average = grades_average(scores) for n in scores: variance += (average - n) ** 2 result = variance / len(scores) return result def grades_std_deviation(variance): return grades_variance(variance)** 0.5 print grades_std_deviation(grades)
Oops, try again. grades_std_deviation(4.0) raised an error: 'float' object is not iterable
Is there something I need to use other than a for loop? How am I supposed to handle an input for both a list and a float?