Reggie's Linear Regression Project (help?)

Hi :slightly_smiling_face:
I just completed the “Reggie’s Linear Regression” project as a part of my Python Fundamentals for Data Science (Part II) course. I am brand new to Python and coding in general and would appreciate a review/some help with my code!
Was feeling pretty confident until I hit Part 12 of the project. I noticed the value my code returned for “smallest_error” and it’s corresponding m and b values differed from Codecademy’s but I’m not sure where I went wrong as I was getting the correct answers up until that point.

Project Link

Link to my code

(I’m also new to GitHub so I hope that link worked.)

Thanks in advance for any insight!

Hello! I’m also taking the Data Science course and a beginner here as well.
I noticed your code is using a different datapoints list from the one that is used by the project, which is indicated part 1, task 4. I think that’s why you are getting different values.

datapoints = [(1, 2), (2, 0), (3, 4), (4, 4), (5, 3)]

I also think you could simplify your code by removing the function line y = () as it isn’t necessary to have it explicit and the formula is pretty clear in itself. You could even try to simplify it even more by returning the result of the expression directly.

return (m*x) + b

The get_y function could be used inside your calculate_error to make it useful and to avoid repeating the formula.