我试图解决Coursera(Python)中的这个非常基本的问题:
- Write two functions, one called addit and one called mult. addit takes one number as an input and adds 5. mult takes one number as an input, and multiplies that input by whatever is returned by addit, and then returns the result.
我的尝试:
def mult(x,y):
return x*addit(y)
def addit(x):
return x+5
The error message:
ERROR None None Error: TypeError: mult() takes exactly 2 arguments (1 given)
Pass 6 6 Testing the function addit with input 1 (should be 6)
Pass 3 3 Testing the function addit with input -2 (should be 3)
Pass 5 5 Testing the function addit with input 0 (should be 5)
所以它传递给了所有测试,但是有一条错误消息说“TypeError:mult()正好接受2个参数(给定1个)”
我真的不明白,我在mult函数中给出了两个参数“x”和“y”
这正是您的问题:赋值明确指定
mult
只接受一个参数。请修复您的函数,然后重试相关问题 更多 >
编程相关推荐