Function Syntax 6 else: syntax error


#1

I'm not sure what is wrong with my code, I keep getting this syntax error

File "python", line 4
else:
^
SyntaxError: invalid syntax

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


#2

Let's review the instructions and see where you went wrong...

Instructions
* First, def a function called cube that takes an argument called number. Don't forget the parentheses and the colon!
* Make that function return the cube of that number (i.e. that number multiplied by itself and multiplied by itself once again).
* Define a second function called by_three that takes an argument called number.
* if that number is divisible by 3, by_three should call cube(number) and return its result. Otherwise, by_three should return False.

Your first function takes care of points 1 and 2. But that's when things begin to break down. See if you can put the code right by following this example pattern:

def by_three(number):
    if number % 3 == 0:      #  note the % (remainder) operator
        return cube(number)
    else:
        return False

Now we need to test our work:

print by_three(11)
print by_three(12)
print by_three(13)