7/19 where do you return by_three and cube?


#1

def cube(number):
return number * number * number

def by_three(number):
if number % 3 == 0:
print "n is divisble by 3"
return by_three
else:
return False

Please help


#2

The problem you are supposed to be returning the cube of the number in the second method but you are instead returning by_three which is a function why it doesn't work you can solve that problem by doing this

return cube(number)

Also here is a hint on modifying your code

def cube(number):
    return number**3

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

    
print by_three(6)

You can also check out this snippet here
Click here to go to labs


#3

Hi,

For the same problem, I get an error saying 'cube(1) returned False instead of 1'. Can anyone identify whats wrong and in the code and suggestions on getting it right.

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

Thank you.


#4

the error is in you cube function implementation this line

def cube(number):
    return cube == number **3

should rather be

def cube(number):
    return number **3

#5

@rydan Thank you very much


#6

Hi,
I also have the problem, couldn't resolve the message error:
Oops, try again.
Did you define a function called by_three?
after writing this code:

def cube(number):
return number **3

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

can you help?
Thanks


#7

this line

def by_tree(number):

should be

def by_three(number):

#8

yep, i forgot the H.
thanks


#9

I'm a begginer but here's a better verison of your code.

def cube(number):
x= (number)**3
return ((number)**3)

def by_three(number):
if (number) % 3 == 0:
print("n is divisible by 3")

 else:
    return (number)