mardi 20 mars 2018

Get random items from range of list

Let's say I have a unsorted set of items:

input = set([45, 235, 3, 77, 55, 80, 154])

I need to get random values from this input but in a specific range. E.g. when I have

ran = [50, 100]

I want it to return either 77 or 55 or 80. What's the fastest way to get this for large sets in python?




Aucun commentaire:

Enregistrer un commentaire