Practice makes perfect


def cube(number):
return number**3

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

where am i going wrong?


Is by_three supposed to return the cubed value?


im not quite sure. im just totally confused


What do the instructions say? (Please post a link to the exercise. Thanks).

Your code is printing the cube, instead of returning it. And it is printing False. We need to check that.




1. First, def a function called cube that takes an argument called number. 
   Don't forget the parentheses and the colon!
2. Make that function return the cube of that number (i.e. that number multiplied
   by itself and multiplied by itself once again).
3. Define a second function called by_three that takes an argument called number.
4. if that number is divisible by 3, by_three should call cube(number) and 
   **return** its result. Otherwise, by_three should **return False**



This is code for "check the instructions if they say so" and "then check if you're doing that in your code"

Finding out what's wrong with code isn't something that just pops out at you, it comes from asking questions designed to narrow down where the problem could possibly be


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