Practice makes perfect - cube

I was doing this exercise and wrote my code, but unfortunately there seems to be a mistake in my code. Could someone please help me see what’s the problem with it: I made sure all the indentations are correct.Thanks

def cube(n):
  return n**3
def by_three(n):
  if n % 3 == 0:
    return cube(n)
  else:
    print("False")

what is the error you are getting? Which exercise is this? Please share exercise url

Thanks for the response. The excercice is called “Practice makes Perfect”. It basically just tries to teach how to call a function within another one.
The error says: by_three(1) resulted none.

Looks like from the error message that you are supposed to return the result rather than print it.

1 Like

None indicates the absence of a return value, as mentioned by midlinder, also, why return a string? Why not a Boolean?

1 Like

The exercise, Functions: Practice Makes Perfect, includes this in the instructions:

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

So, yes, it is asking the user to return a boolean, namely False, under a specified circumstance.