Unsupported operand types


#1



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


Oops, try again. by_three(1) resulted in an error: unsupported operand type(s) for %: 'function' and 'int'


I expected the code to work, but it didn't.


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


#2

Here you are attempting to do math (an integer operation) on a function. Use the parameter variable in the expression, not the name of the function.

Have to ask, did you miss the reading and examples of exponents and exponentiation?

# where `n` is a number, and `x` is the exponent, we write,

n ** x

#3

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