我正在尝试定义一个函数,该函数返回没有该列表中第一个和最后一个项的列表.但是,当我运行该函数时,我得到了这个:"TypeError:'builtin_function_or_method'对象不支持删除项目".
到目前为止这是我的代码:
def middle(t):
"""returns a copy of a list with the first and last items removed
list -> list"""
t = input
del t[0]
del t[-1]
print(t)
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏.
| 归档时间: |
|
| 查看次数: |
229 次 |
| 最近记录: |