Oops, try again. cube(1) returned 2 instead of 1

```
Replace this line with your code.
def cube(number):
return number^3
def by_three(number):
if number%3==0:
return cube(number)
else:
return False
```

Oops, try again. cube(1) returned 2 instead of 1

```
Replace this line with your code.
def cube(number):
return number^3
def by_three(number):
if number%3==0:
return cube(number)
else:
return False
```

All good except for this:

Raising a number to a power is done using **.

See full below

```
def cube(number): #cube function with number parameter
return number**3 #returns cube of number
def by_three(number):
if number % 3 == 0:
return cube(number)
else:
return False
```

@ bayoishola20 i have the exact same code:

def cube(number):

return number**3

def by_three(number):

if number % 3 == 0

return cube(number)

else

return false

here is your code:

def cube(number):

return number**3

def by_three(number):

if number % 3 == 0:

return cube(number)

else:

return False

it says my code is wrong?? HELP!!

I would have loved you format your code since this language is indentation sensitive.

Well, we do not have exactly the same code.

Here,

Where as mine is:

Observe that you missed the colon after else and that will affect indentation. Also, it is * False* and not

does anyone know why on line 4:

if number%3==0

has to be equaled to 0?

Is it because then it is false?

when i didn't add the 0 it said it comes out as 1 instead of false.

or you can do this

def cube(number):

return number * number * number # it is slow than #number**number

def by_three(number):

if number % 3 == 0 :

return cube(number)

else :

return False

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