Seams to work but says its wrong


#1


https://www.codecademy.com/courses/python-beginner-c7VZg/1/5?curriculum_id=4f89dab3d788890003000096

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

if I put a number that is divisible by three it should call cube and cube that number. if not divisible by three it should return false

def cube(number):
  number = number**3
  return(number)  
def by_three(number):
    if number / 3:
        return cube(number)
    else:
        return False
answer = by_three(1)
print(answer).


#2

here:

    if number / 3:

how does this determine is number is divisble by 3?


#3

In your if statement, you have code that says if number / 3. It does not provide an actual condition. You're actual code should read:

If number % 3 == 0:

This way, the computer is able to check if the number is evenly divisible by three.


#4

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