Practise Makes Perfect


#1

I keep getting the same error almost all the time unless I make changes to the indentation, which completely breaks the function.

def cube(number):
    return number**3
    if number % 3 == 0:
        return cube(number)
    else:
        return False

I get the error
"Oops, try again. by_three(1) resulted in an error: global name 'n' is not defined"
But I don't see by_three(1) or n in this code...


#2

They actually asked you to make two functions. Since a function ends when the return keyword is reached, your function ends right on line 2 :slight_smile:.
So, you should reread the instructions and create a second function like they asked.
Do you know what you should do now? :wink:


#3

Hi @blogsurfer36193,

Refresh the page to remove by_three from Codecademy's memory cache. Then, you'll still need to do some work on the code that you have on the page. See @intermediategamer's reply, for example.


#4

Yeah, I'm an idiot. Thanks guys. XD


#5

Hi @blogsurfer36193,

Have you gotten it to work yet? If not, post the most recent version of your code.


#6

Yes, I have. Thank you.


#7