Practice makes perfect lesson

def cube(n):
    return n*n*n
def by_three(n):
    if n % 3 == 0:
        return "by_three(n)" 
        print "n is divisible by 3"
         return "False"
         print "n is not"

I get by_three(1) returned 'False' instead of False


You are expected to return the boolean values True / False but instead you are returning a string
And any line of code that comes after returning a value in the function will be UNREACHABLE(will not be executed)


The first branch of the if statement should be returning the cube of the number, not a Boolean.

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


A post was split to a new topic: New to programming