📅  最后修改于: 2022-03-11 14:45:30.082000             🧑  作者: Mango
def remove_all(items, item_to_remove):
if not isinstance(items, list):
raise TypeError(f'invalid list type {type(items).__name__}')
last_occurrence = False
while not last_occurrence:
try:
items.remove(item_to_remove)
except ValueError:
last_occurrence = True