drop_right()
Creates a slice of `array` with `n` elements dropped from the end.
Implementation
Args: array: List to process. n: Number of elements to drop. Defaults to ``1``. Returns: Dropped list.
Example
drop_right([1, 2, 3, 4], 2)
Expected output: [1, 2]
Source Code
def drop_right(array: List[T], n: int = 1) -> List[T]:
return array[:-n] if n else list(array)