为什么remove()不会删除指定的值?

Tin*_*ing 1 list python-2.7

list = ['02', '03', '04', '05', '06', 'Inactive', 'Inactive', 'Inactive', 'Inactive', 'Inactive']

list.remove('Inactive')

print list
Run Code Online (Sandbox Code Playgroud)

但它只是保持结果不变.我错过了什么?

msh*_*yem 6

它移除第一次出现Inactive列表的文档remove的方法说.要删除所有匹配项,请使用loop/method/lambda/LC.例如:

myList = ['02', '03', '04', '05', '06', 'Inactive', 'Inactive', 'Inactive', 'Inactive', 'Inactive']
removedList = [x for x in myList if x!='Inactive'] # original list unchanged    
# or
removedList = filter(lambda x: x!='Inactive', myList) #leaves original list intact
Run Code Online (Sandbox Code Playgroud)

顺便说一句,不要list用作变量名