Q:

Add numbers to the beginning of lists

I have a list of list, say X, that looks like this
X_train = [[4,3,1,5], [3,1,6,2], [5,0,49,4], ... , [3,57,3,3]]

I wrote this piece of code
for x in range(0,len(X_train)):
    X_train[x].insert(0, x+1)

For each list in X this code inserts the index value of the list + 1 to the beginning of the list. That is, running
for x in range(0,len(X_train)):
    X_train[x].insert(0, x+1)
print(X)

will produce the following output
[[1,4,1,5],[2,3,1,6,2],[3,5,0,49,4],...,[n,3,57,3,3]]

where n is the number of lists in X.
Question: Is there a faster way to do this? I would like to be able to do this for very large lists, e.g. list with millions of sublists (if that's possible).

A:

This is faster in my testing:
X = [[n, *l] for n, l in enumerate(X, 1)]

