i have a list with 9000 list items as strings, i want to select 4000 instances randomly amongst them. how can i achieve this. I have write down a code.
from random import randint
for r in range(9000):
print(randint(9000))
- first i will generate the random 4000 random number
- and then list members will be picked up by the selected random numbers I have write down a code which is showing an error code is as given bellow
random.samplecould help if you want to selectkrandom items out of all possible items.random.shuffleand list splicing could be useful depending on what you want to do with the info