# Python : Functions : Practice Makes Perfect

#1

It keeps telling : Oops, try again. cube(2) returned False instead of 8

How can I solve this ? I know that 2/3 = 0,... So, I believe the condition is applied here.

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

#2

Hi @selim92,

Here ...

``````   if number >= 0 :
return number == number**3``````

... you have the function `return` the value of `number == number**3` instead of the value of `number**3`.

Here ...

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

... you have the function `return` the value of `by_three(number) == cube(number)` instead of the value of `cube(number)`.

#3

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

This code works. You cannot put "==" in place of "=" in line 3.

#4

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