6. Practice Makes Perfect - Help please!


#1

Hello, there!

I am having a hard time with this exercise. Could someone check my code and tell me what I am doing wrong?

THANKS!


https://www.codecademy.com/courses/python-beginner-c7VZg/1/5


Did not work

it's not printing False, it returns None


def cube(number):
    """ My Cube function"""
    return cube(number ** 3)

def by_three(number):
    """ by three function """
    if number % 3 == 0:        
        return cube(number)    
    else:    
        return False


#2

From the instructions:

Make the cube function return the cube of that number

Why does your cube function call itself? This causes maximum recursion depth (sort of like an infinity loop, only with functions)


#3

hey stetim94, thank you very much for the quick reply and spot my error, I just removed the unnecessary code and it worked!

def cube(number):
""" My Cube function"""
return number ** 3

def by_three(number):
""" my by three function"""
if number % 3 == 0:
return cube(number)
else:
return False


#4