Maximum Recursion Depth exceeded


Hi, I am getting more issues now... I've done as the code asked, also had a look to see if I could find a solution from someone else's post, but I can't. I'm getting the maximum recursion depth exceeded error and I have no idea why or how to correct that.

The link to the exercise is:

Any help would be most welcome.

def cube(number):
    cubed = number**3
    return cube(number)
def by_three(number):
    if number % 3 == 0:
        return cube(number)
        return False

I've just edited my code to try and fix it, so that I am not calling the function within the function (on the first block) anymore, and now it is saying that the output is 2 when it should be 8. How do I remedy this? I'm not being lazy, I have googled too.


inside the cube function, you should still return cubed. Just make sure the function call is outside the function, and also post an updated version of your code


I think it is because you return cube(number), which is the starting number (2) instead of 2 cubed
try to :
return number ** 3


cubed = number**3
return cubed


Thanks for your help stetim94, and thank you affanhafizan. You were correct, it was because I was just returning cube(number).