I’m having a problem with the Reggie’s Linear Regression project

https://www.codecademy.com/courses/learn-python-3/informationals/python3-reggies-linear-regression

I’m running this Jupyter source file using VS Code.

In the solution file, In the part regarding the calculate_all_error code:

```
def calculate_all_error(m, b, points):
total_error = 0
for point in datapoints:
point_error = calculate_error(m, b, point)
total_error += point_error
return total_error
```

This is supposed to be the correct solution. That’s what appears in the solution file, in that text box.

right after that, there’s another text box for testing this function:

```
#every point in this dataset lies upon y=x, so the total error should be zero:
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(1, 0, datapoints))
#every point in this dataset is 1 unit away from y = x + 1, so the total error should be 4:
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(1, 1, datapoints))
#every point in this dataset is 1 unit away from y = x - 1, so the total error should be 4:
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(1, -1, datapoints))
#the points in this dataset are 1, 5, 9, and 3 units away from y = -x + 1, respectively, so total error should be
# 1 + 5 + 9 + 3 = 18
datapoints = [(1, 1), (3, 3), (5, 5), (-1, -1)]
print(calculate_all_error(-1, 1, datapoints))
```

Yet, when I run the code in the textbox, I get a NameError.

I guess the NameError appears because the calculate_all_error function is written in a different text box. But this is the **solution** file. It’s supposed to run correctly and smoothly.

Does this problem also happen when using Jupyter Notebook? Is it happening because I’m using VS Code to run the Jupyter file? Is it OK to work on the Jupyter file through VS Code?

Any help would be appreciated.