6. Practice makes perfect


#1

I'm putting in the same code as the people in this forum but it keeps saying:
Oops, try again. cube(1) returned 'number ** 3' instead of 1

Here is my code:

def cube(number):
return "number ** 3"

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


#2

This was my code... you can compare

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

#3

The reason maybe you're using quotes in your second line.

My code :slightly_smiling:

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


#4

I tried your code to see if it worked but it didn't seem to work it said error on line 5


#5

You should indent the code. Thanks.


#6

Im not a hundred percent but I believe the issue is line 5 after your == for the reason that its asking for number to be divisible by 3. In which im guessing they want it to be divided and end up as a whole number without decimals or remainders. For mine I put if number % 3 == int(): and it worked. You might want to try that out since int() makes sure there are no remainders in the answer, just a whole number. Again I am not a hundred percent sure if my reasoning is correct but I do know thats how to fix your code.


#7

Thanks! this was very helpful, I realized it was just my indentation!


#8

This is the answer.