Pyhton - functions - number 6 - problems with the code


#1




The exercise tells me:
"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."

And I wrote this:


def cube(number):
return number **3

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


Where's the mistake ?

Replace this line with your code.


#2

the instructions:

if that number is divisible by 3, by_three should call cube(number) and return its result.

you return number divided by three, not really the same thing, try calling cube()


#3

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