Functions Exercise 6


The exercise states “If that number is divisible by 3, by_three should call cube(number) and return its result”, and this is the correct code.
def cube(number):
return number**3
def by_three(number):
if (number%3 == 0):
return cube(number)
return False
I do not understand why I have to put “return” in front of the italicized “cube(number)”, since I am already returning something in the body of the function cube(number). Wouldn’t this make it so that I am doing return return number. 3?


if you call by_three function, you do want the result returned by the by_three function.

otherwise, we can’t access the calculation done by cube when calling by_three


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