Lets say that my program asks a user to input a number indefinitely and I appended it in a list.
#Given Example:
List = [105, 167, 262, 173, 123, 718, 219, 272, 132]
what I wanted to do is to randomly pick any of the numbers so my sample output would be:
first = [105, 262, 173]
second = [167, 123, 132]
third = [718, 219,272]
Having said, since the user input would be indefinite there will be chances that it would be an odd number.
I am currently using random.sample to choose a number from that list and append it in a list, after that I'll append the sub-groups of list to create a list within a list.
Would be a great help if anyone answers, thanks!
Aucun commentaire:
Enregistrer un commentaire