Of yhat types are data_list and train_indices? The first posted list(k) doesn’t seem to be used in the second code snippet.
PS: you can post code snippets by wrapping them into three backticks ```, which would make debugging easier.