Practice makes perfect


#1

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)
else:
print "False"


Practice makes perfect
#2

here:

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


#3

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