Python 属性错误:';内置函数或方法';对象没有属性';流行音乐';

Python 属性错误:';内置函数或方法';对象没有属性';流行音乐';,python,python-3.x,Python,Python 3.x,这是我的密码 def allButMax(): input_list=[] user_input = 0 num_sum = 0 max_num = 0 while user_input != "end": input_list.append(float(user_input)) user_input = input("Enter next number: ") input_list = input_list[

这是我的密码

def allButMax():
    input_list=[]
    user_input = 0
    num_sum = 0
    max_num = 0

    while user_input != "end":
        input_list.append(float(user_input))
        user_input = input("Enter next number: ")


    input_list = input_list[1:]

    input_list = input_list.sort


    input_listnew = input_list.pop(-1)


    for num in input_list:
     num_sum = num_sum + num

    print("The num of all values except for the maximum value is: ", num_sum)
当我运行程序时,它说

AttributeError:“内置函数”或“方法”对象没有属性“pop”

该程序计算除序列中的最大值外所有输入值的总和


我不知道哪里出了问题

问题出在这条线上

input_list = input_list.sort
input\u list.sort
实际上没有被调用。您只是在
input\u list
中存储对该函数的引用,从而对列表进行NUK操作

sort
是一种就地方法,它对列表本身进行操作,而不是返回列表的新排序副本(请参见
sorted
)。它返回
None
,因此不应尝试从其返回值赋值

替换

input_list = input_list.sort


正确,但是这个问题是离题的,应该结束了。这个错误是因为输入错误而引起的。我建议删除这个答案并发表评论。
input_list.sort()