im just learning to program here , so bear with me here.
Im learning to code on Codeacademy and have an assignment, but cant figure out for the life of me what im doing wrong.
First i need to define a function that returns the cube of a value, than i should define a second function that checks if a number is diviseble by 3, if it is i need to return it , else i need to return a false
heres the code:
if b % 3 == 0:
You are not catching the return value of the function
b = cube(b). Or better yet, do
def cube(c): return c**3 def by_three(b): if b % 3 == 0: b = cube(b) return b # Or simply return cube(b) and remove `b = cube(b)` else: return False
When you call the
cube function with the argument
b, it returns the cube of the passed argument, you need to store it in a variable and return that to the user, in your current code, you are neglecting the returned value.