Functions: "Practice Makes Perfect" Problem


Look at this. What is the problem?

The error is: by_three(1) returned 1 instead of False

I expected the code would return False

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


to check if a number is divisble by 3 the remainder should equal zero.

inside your by_three function, call cube, don't do the math again


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