Unsupported operand types



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)
        return False;


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


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