def sort_and_pop(x: list, i: int) -> list:
x.sort()
return x.pop(i)
lst = [23, 17, 3, 13, 11, 5, 7, 2, 19, 1]
lst = sort_and_pop(lst, 5)
lst = sort_and_pop(lst, 2)
如何修改 (x: list, i: int) -> list:
使得
我的代码显示错误 而不是AttributeError
def sort_and_pop(x: list, i: int) -> list:
x.sort()
if i in x:
x.remove(i)
return x
lst = [23, 17, 3, 13, 11, 5, 7, 2, 19, 1]
lst = sort_and_pop(lst, 88)
lst = sort_and_pop(lst, 2)
print(lst)