Correct answer but still have errors - standard deviation

Screen Link: Learn data science with Python and R projects

My Code:

from math import sqrt

def standard_deviation(array):
    reference_point = sum(array) / len(array)
    distances = []
    for value in array:
        squared_distance = (value - reference_point)**2
    variance = sum(distances) / (len(distances) - 1)
    return sqrt(variance)

st_devs = []
import matplotlib.pyplot as plt

for i in range(5000):
    sample = houses['SalePrice'].sample(10, random_state = i)
    st_dev = standard_deviation(sample)

What I expected to happen:
Nice work

What actually happened:

st_devs isn’t defined in your code, but we expected it to be list type

The code is exactly same as answer, don’t understand why it has error.

1 Like

Hi @ipngasi,

I tried to run you code, it works now.
Please try it again.