So basically i have 10 txt files(named A_1,A_2........A_10), i want to randomly select 3 files out of these 10 in a way, when those 3 files are randomly chosen, they will be removed from the original list and a new list can be created using the randomly chosen 3 files.I tried the following method, but when i try the command print(filelist), it still shows the 10 txt files,Any suggestion or advice will be really helpful.
import random
filelist=[]
for i in list(range(1,11)):
filelist.append("/Users/Hrihaan/Desktop/A_%s.txt" %i)
Newlist=random.sample(filelist,4)
Aucun commentaire:
Enregistrer un commentaire