• + 1 comment

    marksheet is a 2D array, something like [["Sally", 20.3], ["John", 19.5], ["Susan", 21.2]].

    So name, marks effectively destructures each element in the 2D array. For every element, name gets bound to the first item, e.g. "Sally", and marks gets bound to the second item, e.g. 20.3. So we iterate through the 2D array, and for each element, we return only the second item in the subarray, and we end up with a 1D array like this: [20.3, 19.5, 21.2].

    The code is slightly misleading because as the list comprehension iterates over the 2D array marksheet, it's only looking at 1 mark at a time. So perhaps, it should have been written [mark for name, mark in marksheet].

    Does that make sense?