Reading a random element from a set
ast
nomail at com.invalid
Wed Jul 26 02:58:03 EDT 2017
More information about the Python-list mailing list
Wed Jul 26 02:58:03 EDT 2017
- Previous message (by thread): Python BeautifulSoup extract html table cells that contains images and text
- Next message (by thread): Reading a random element from a set
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello
random.choice on a set doesn't work because sets are
not indexable
so I found nothing better than taking an element and
puting it back
a = {5, 7, 8, 3, 0, 8, 1, 15, 16, 34, 765443}
elt = a.pop()
a.add(elt)
any better idea, in a single instruction ?
- Previous message (by thread): Python BeautifulSoup extract html table cells that contains images and text
- Next message (by thread): Reading a random element from a set
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list