Help with an error in the code


#1


  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
cube()

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


#2

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

#3

Thanks a lot!!
it worked.


#4

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