I have a simple code where I want to update the variable names as follows:
n = 5
for i in range(0, n):
train_fold_[i], val_fold_[i] = result[i][0],result[i][1]
I want the above code to generate a total of 10 variables with names train_fold_0, val_fold_0, train_fold_1, val_fold_1,......, train_fold_4, val_fold_4.
However, when I run this code, it is only generating 2 variables as follows: train_fold_i, val_fold_i.
I know this is extremely simple, but can someone please help me out with this as I'm relatively new to python.
train_fold, val_fold = zip(*[result[i] for i in range(n)]). You can now access your ten values astrain_fold[0],val_fold[0],train_fold[1], etc.n == len(result)you can do it more simply:train_fold, val_fold = zip(*result)