Functions: Practice Makes Perfect


#1

Hi I've been stumped with a syntax error that keeps on appearing with this lesson. My code ends up looking like this:


def cube(number):
    return number**3

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

When I run the function I keep on getting the following:
File "python", line 5
if: number % 3 == 0
^
SyntaxError: invalid syntax

I'm not sure what I'm doing incorrectly.

Thanks in advance


#2

In the if statement colon should be placed after the condition:

if number % 3 == 0:

:slight_smile:


#5