AttributeError: 'function' object has no attribute 'remove'

AttributeError: 'function' object has no attribute 'remove'

大家好我正在尝试创建一个程序,该程序采用最小分数并将其删除并对其他分数进行平均并给出结果但是当我尝试使用删除函数删除最小分数时我遇到了这个错误

回溯(最后一次调用): 文件“main.py”,第 6 行,位于 datos.remove(min) #que esta mal? AttributeError: 'function' 对象没有属性 'remove'

这是我的代码

 def datos(nota1, nota2, nota3, nota4, nota5):
  min = datos[0]
  for i in datos:
    if(min>i):
      min=i
datos.remove(min) #what is wrong?
prom = 0
for i in datos:
  prom+=i/len(datos)%prom
print(datos('AA0010276',40, 50, 39, 76, 96))

我是 Python 的新手,所以我真的不知道它是如何工作的,如果有任何意见可以更正此错误,我将不胜感激 :D

PS: 部分代码为西班牙语

您将数据视为列表对象,但事实并非如此。它是一个函数,不支持迭代,也没有remove属性。

基本上你的程序全错了

查看工作示例:

def remove_minimum_and_calculate_average(notes:list )-> float:
    return sum(notes[1:])/len(notes[1:])

notes = [1,5,10]

print(remove_minimum_and_calculate_average(notes))

7.5