Week 2 Linear Regression Lab - "w" not defined error

Here is the error I keep getting for UNQ_C2

NameError Traceback (most recent call last)
26 for i in range(m):
27 # Your code here to get prediction f_wb for the ith example
—> 28 f_wb = w * x[i] + b
30 # Your code here to get the gradient for w from the ith example

NameError: name ‘w’ is not defined

Not sure why this is happening? Especially since this error didn’t come up earlier in the lab when I first had to define f_wb.


Check the variable w is defined in the function you are in or being passed as an argument to the function.

Also, check your capitalization it might be W not w as uppercase not lower.

Check that your code is indented correctly.

Python is extremely specific in how it uses indentation to define code blocks and funtions.