-4
给定一个整数数组,删除最小值。不要改变原始数组/列表。如果有多个具有相同值的元素,请删除索引较低的元素。如果你得到一个空的数组/列表,返回一个空的数组/列表。python列表/数组中的最小数字
不要改变剩下的元素的顺序。
例
remove_smallest([1,2,3,4,5]) = [2,3,4,5]
remove_smallest([5,3,2,1,4]) = [5,3,2,4]
remove_smallest([2,2,1,2,1]) = [2,2,2,1]
这是我的代码
def remove_smallest(numbers):
if numbers == []:
raise NotImplementedError("TODO: remove_smallest")
numbers = list(numbers)
numbers.remove(min(numbers))
return numbers
我在这个追溯错误NotImplementedError("TODO: remove_smallest")
家庭作业? – trincot
如果列表为空,则不要执行任何操作... –
您的代码对我来说工作正常。你必须传递一个空数组。但是由于您没有显示实际发生错误的内容,因此您的帖子在解决问题方面做得并不好,我们可以帮助您解决问题。 –