I was looking at this python code that I need some explanation with:
arr = [0, 0, 0, 0, 1, 2, 3, 4,5]
arr = arr[next((i for i, x in enumerate(arr) if x != 0), len(arr)):]
This code would remove the leading zeroes from the array, I am trying to understand how it works. I understand that we created an iterator that would iterate over all elements of arr
but 0 values, and next would iterate only till length of array (not inclusive).
But how are these indices returned by next, combine to form an array?