Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Remove item from list

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
Source by alexandra-zaharia.github.io #
 
PREVIOUS NEXT
Tagged: #Remove #item #list
ADD COMMENT
Topic
Name
3+6 =