I have a list with integers. I want to choose 80% from them. For example, for [1,...,30] I want to keep 80% from the list with random so I get for example [1,...,32][3,7,19,21,25,29] (It means it deleted 3,7,19,21,25,29 values from the original list. How can I do it?
80%
[1,...,30]
random
[1,...,32][3,7,19,21,25,29]
3,7,19,21,25,29
import random random.sample(lst, k=round(len(lst) * 0.8))
2.1m questions
2.1m answers
60 comments
57.0k users