Hep with Practice makes Perfect


#1



I'm having some trouble with this:

def cube(number):
return cube == 1 / 1 / 1

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

I don't know why it does not work and whenever I press "Save & Submit" it comes up with an error saying:

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



#2

The error tells you that your function will not give desired test output. Hence, you should re-write.

You will want to:

return number**3 #returns cube of number

Also, here:

you will want to do:

if number % 3 == 0:

which is a condition that if the number is divisible by 3 with no remainder.

PS: Ensure indentation is right.

Hope this helps! :slight_smile:


#3

its now giving an error code that says:

Oops, try again. cube(1) resulted in an error: unsupported operand type(s) for ** or pow(): 'function' and 'int'


#4

Nevermind, it works now


#5

Okay, good to hear that.

Sorry for the late reply, though.

Have fun coding. :slight_smile:


#6

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