版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhaoluwei/article/details/86136826
eg:输入:
[1, 2, 3, 4, 3, 5, 3]
删除:3
结果: [1, 2, 4, 5]
def shan(lt, item):
count = lt.count(item)
if count == 0:
print('没有元素,不能删除')
return
for i in range(count):
lt.remove(item)
return lt
print(shan([1, 2, 3, 4, 3, 5, 3],3))