Help with an error in the code


  1. Functions - Practice Makes Perfect

    This are the error message I get:
    Traceback (most recent call last):
    File "python", line 3, in
    TypeError: cube() takes exactly 1 argument (0 given)

can't understand what's the problem

Thanks a lot!

def cube(number):
    return number ** 3

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


That line may be removed.

The above line will also raise the same exception. Be sure to include an argument:

print by_three(42)    # 74088


Thanks a lot!!
it worked.


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