Functions: "Practice Makes Perfect" Problem


#1



Look at this. What is the problem?

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


The error is: by_three(1) returned 1 instead of False


I expected the code would return False


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


#2

to check if a number is divisble by 3 the remainder should equal zero.

inside your by_three function, call cube, don't do the math again


#3

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