def remove_section(alist, start, end):
"""
Return a copy of alist removing the section from start to end inclusive
>>> inlist = [8,7,6,5,4,3,2,1]
>>> remove_section(inlist, 2, 5)
[8, 7, 2, 1]
>>> inlist == [8,7,6,5,4,3,2,1]
True
>>> inlist = ["bob","sue","jim","mary","tony"]
>>> remove_section(inlist, 0,1)
['jim', 'mary', 'tony']
>>> inlist == ["bob","sue","jim","mary","tony"]
True
"""
我有点为难如何继续做这件事,任何帮助都将是非常感谢的。
最佳答案
这应该符合您的要求:
def remove_section(alist, start, end):
return alist[:start] + alist[end+1:]