Function 6. Practice makes perfect


I need help with this lesson in the Functions session of Python. I cannot figure out what is going wrong, it may be something very stupid. I'm prone to making silly errors so if anyone could help me out it would be much appreciated :smiley:

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

def cube(number):
     return number**3

def by_three(number):
     if number / 3 == 0:
         return cube(number)
         return False


Consider that the only quotient equal to zero is division into zero.

0 / n == 0    n != 0

and division by n is not evidence of divisibility. The remainder serves that role.

number % 3 == 0


No way!!! Haha thanks!! That makes sense too because no number divided by another will be zero, other than zero.


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