Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 我得到以下错误:TypeError:avg_1()接受0个位置参数,但给出了1个_Python 3.x - Fatal编程技术网

Python 3.x 我得到以下错误:TypeError:avg_1()接受0个位置参数,但给出了1个

Python 3.x 我得到以下错误:TypeError:avg_1()接受0个位置参数,但给出了1个,python-3.x,Python 3.x,回溯(最近一次呼叫最后一次): 文件“”,第1行,在 def avg_1(): print() avg_1(['nancy',('math',70),('english',90),('science',90),('history',80)]) TypeError:avg_1()接受0个位置参数,但给出了1个 任何帮助都将不胜感激。avg_1()不接受参数 但你用一个论点来形容它 ['nancy',('math',70),('english',90),('science',90),(

回溯(最近一次呼叫最后一次):

文件“”,第1行,在

def avg_1():

    print()

avg_1(['nancy',('math',70),('english',90),('science',90),('history',80)])
TypeError:avg_1()接受0个位置参数,但给出了1个

任何帮助都将不胜感激。

avg_1()
不接受参数

但你用一个论点来形容它

['nancy',('math',70),('english',90),('science',90),('history',80)]

要打印列表,您需要在
avg_1()
中有一个参数:

现在函数中的
prt
等于
['nancy',('math',70),('english',90),('science',90),('history',80)]
在函数avg_1中


因为函数avg_1的定义不接受任何参数,所以必须将其更改为“def avg_1(某些元组列表)”
avg_1(['nancy',('math',70),('english',90),('science',90),('history',80)])
def avg_1(prt):

    print(prt)

avg_1(['nancy',('math',70),('english',90),('science',90),('history',80)])