Practice Makes Perfect (unusual error)


cube(1) resulted in an error: maximum recursion depth exceeded

def cube(number):
    return cube(number)
def by_three(number):
    if  number %  3:
        return cube(number)
        return False


Hi, @cunycodemaster2k4,

Regarding the cube function, the instructions state ...

Make that function return the cube of that number (i.e. that number multiplied by itself and multiplied by itself once again).

However you have the function call itself, which is an example of recursion.

Consider using the ** operator to perform the math within the function, or using the * operator twice.

In the by_three function, the condition in this if header needs to be revised ...

    if  number %  3:


A post was split to a new topic: Practice Makes Perfect - Error


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.