6. Practice makes perfect code not working, don't know why


#1



I am stuck on function syntax no. 6 Practice Makes Perfect


It is returning an invalid syntax error message on statement (if number % 3 == 0)


this should allow the program to check if the number is divisible by three


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

cube(2)
by_three(2)


#2

You forgot the colon after the "if" statement in your by_three function.


#3

def cube (number) :
return number ** 3

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

cube(2)


#4

thanks so much. I'm still very new to this obviously. I also ended up having to assign the cube variable to the by_three if: return which was very confusing at first.


#5

RIP I do that so much.


#6

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