from typing import List, Any def list_remove_all_occurrences(l: List[Any], value: Any) -> None: """ Remove all occurrences of a given value from a list **in place** See https://stackoverflow.com/a/48253792 """ i = -1 # Shift elements that should not be removed for i, v in enumerate(filter(value.__ne__, l)): l[i] = v # Remove the tail del l[i + 1: len(l)]