# Week 3 practice lab: logistic regression. Exercise 6

I’ve been having the same error even if i changed the code over and over again, this is the error:
“RecursionError: maximum recursion depth exceeded”
Can someone help? I can post my code and I’m sure there’s no problem with it because I didn’t face any problems with the previous Exercises

That error means you’ve written code that calls itself. That’s a “recursion”. It’s not good.

Check if you are calling your function from inside that same function.

If there was no problem with your code, you wouldn’t be getting error messages.

I know what is recursion but the case I’m seeing in my code doesn’t have any recursion cases, I followed the hints and It’s similiar to my code.
So what’s the case I’m facing?

Maybe you’re calling a function that in turn calls that function itself.
A → B → A → B, etc.

I.e. maybe you’ve created a chain.

At the end of each code, there is the expected answer for each code, and my answer matches that answer, so why aren’t my correct answers corrected?

The test cases don’t prove your code is perfect. They only make a few basic checks.

Somewhere, you’ve written code that calls itself, either directly or indirectly.

Please post a screen capture image that shows the error message. Maybe it has some clues you haven’t picked up on.

{edited}

inside the compute_gradient_reg() function, you should not add any code until you get to the “START CODE HERE” section, as I’ve marked below.

From your image, in the lines marked 6, 7, and 8, did you add those lines into the gradient_descent_reg() function?

Because if you did, that’s the problem. Line 7 creates a definition of the function, within a function that has the same name.

You should not have added lines 6 through 10 to that function.

I solve that problem, cells save their first output and do not change it unless you restart and clear the cell’s output from the kernel in order restart and clear output then when you submit it will save the last change of output value.

Tips:
You don’t have to restart the kernel, you can simply re-run all the cells in the notebook.

When you modify a cell, you have to then run the code in that cell (shift-ENTER) before it becomes active. Just editing a cell does not update the code in your workspace.

Before you submit for grading, be sure you save your notebook first. Notebooks do not immediately save automatically.

The grader always uses the default notebook name. So never re-name a notebook.