Excluding header

For this code,
if header:
return data[1:], data[0]
else:
return data

Can you remind me why [1:] excludes the header row and why data[0] returns the entire data set?

The header row is going to be the first list in the dataset, data[0]. So data[0] actually returns the header row only. When we use the slice data[1:], we’re asking for all the rows from index 1 onward (which excludes the header row at index 0).