Function: Practice makes perfect infinite loop error


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


This is the cause. Just, return cube(number).


Thank you! Do you know why? the directions say to have by_three call cube(number) and return its result. Am I misunderstanding what its asking or misunderstanding how to call a function?


When the function makes the call to cube(), that function sends a return value back to the caller. Then it is returned to the by_three caller.

def by_three(number):
    # ...
    return cube(number)


ohhh I understand now. thank you so much!


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