Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Index Delete solution in Clear category for Remove All Before by Striga
from typing import Iterable
def remove_all_before(items: list, border: int) -> Iterable:
border_index = items.index(border) if border in items else -1
if border_index > -1:
del items[:border_index]
return items
if __name__ == '__main__':
assert list(remove_all_before([1, 2, 3, 4, 5], 3)) == [3, 4, 5]
assert list(remove_all_before([1, 1, 2, 2, 3, 3], 2)) == [2, 2, 3, 3]
assert list(remove_all_before([1, 1, 2, 4, 2, 3, 4], 2)) == [2, 4, 2, 3, 4]
assert list(remove_all_before([1, 1, 5, 6, 7], 2)) == [1, 1, 5, 6, 7]
assert list(remove_all_before([], 0)) == []
assert list(remove_all_before(
[7, 7, 7, 7, 7, 7, 7, 7, 7], 7)) == [7, 7, 7, 7, 7, 7, 7, 7, 7]
Sept. 20, 2020