Practice makes perfect


Hi guys
my code seems to show maximum recursion depth exceeded I dont understand
here is my code:
def cube(number):
return number**3

def by_three(number):
if by_three(number) % 3 == 0:
return cube(number)
print "False"

Practice makes perfect


if by_three(number) % 3 == 0:

you call the function inside the function, this is called recursion. But given there is no way for your recursion to end, you reach the maximum recursion depth. Sort of like an infinity loop


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