You can calculate all the indexes first to avoid rewriting and reloading the data again.
train_Indexs=[]
for i in range(10) :train_Indexs.append([] )
test_Indexs = []
for i in range(10) :test_Indexs.append([] )

for num in range(0,len(trainset.labels)):
    train_Indexs[trainset.labels[num]].append(num)
for num in range(0,len(testset.labels)):
    test_Indexs[testset.labels[num]].append(num)

index_train=train_Indexs[0]#the class u want
 modified_train_labels = [1 if (trainset.train_labels[x] in postive_class) else 0 for x in index_train]#if you want to modify the label
trainset.train_labels=modified_train_labels#train set labels
trainset.train_data=trainset.train_data[index_train]#train set data