I actually had the same issue on a different step. You see, I had just the following simple code:
def gradient_descent(x, y, learning_rate, num_iterations):
b = 0
m = 0
return b, m
And this passed the second step. But later, when I implement the correct code solution (take my word for it, I don’t know if it is allowed for me to just post my solution on the forum) I get stuck on step 4. I also produced the, “Does gradient_descent
take 4 parameters?” error. But this makes no sense since I made it to step 4, and at no point do I change the number of parameters for that function.
I had to use the “View Full Solution” option just to proceed, which really sucked because their solution was virtually identical to mine (one tiny difference being that their solution used return [b, m]
and my solution was return b, m
, which are both valid ways to return two variables from a function as far as I know).
I filed a bug report for this, but it is frustrating that there isn’t way to view the normal console and the localhost at the same time, because maybe I would have had a more informative answer from the console if there was really an error or a failed test case of some sort, rather than that bogus error question that Codecademy produced. That, or maybe add a hint to Step 4 to show the correct “solution,” i.e. the exact identical syntax that Codecademy needs to allow you to proceed to Step 5.
EDIT
I was horribly mistaken. After trying again, and still being confused, I realized that I must be on auto-pilot and was being dumb. In my solution, for the loop, I defaulted to my normal style and used for x in range(num_iterations)
. This obviously cannot work since x
is the parameter to take in the x-axis data.
I still think that the inability to view the console and the bad error message “Does gradient_descent()
take 4 parameters?” is an issue of some sort that needs some kind of resolution. But, I was very wrong about my code being correct. Apologies.