I can’t run a simple for because I get this error
You must have used the python reserved word range
as a variable name someplace. python will let you do that, but it is not a good idea for exactly the reason you see here. In other words, look through your earlier code and see if you say something like:
range = np.zero((4,1))
or
range = 42.
anywhere. In fact you can see that the value that range
has is 17.17....
in the print output you show. So how did that happen?
Here is some demo code to show the type of problem I’m talking about.
First a normal use of range
:
v = np.array(range(8))
print(f"v = {v}")
print(v[0:4])
v = [0 1 2 3 4 5 6 7]
[0 1 2 3]
All fine and dandy. Now watch this:
print(range)
range = 42.
v = np.array(range(8))
<class 'range'>
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-2602a35c29cc> in <module>
1 print(range)
2 range = 42.
----> 3 v = np.array(range(8))
TypeError: 'float' object is not callable
That error message looks pretty familiar by now, right?
Baam! that’s the error, I suggest that you fix it in the Programming Assignment: Week 2 practice lab: Linear regression, look:
HI @javihm77,
If we are talking about MLS Course 1 Week 2 Assignment Lab for Linear Regression, the code lines that you show on the screenshot do not exist in the lab. You might get a new copy of the lab by following these instructions, in which it will ask you to rename your current lab’s filename so that the system can get you a new copy.
Raymond
@paulinpaloalto thanks a lot, exactly what you say is my problem.
@rmwkwok Now I realized that I added those lines, my bad.