How to select a random element from a set in Python

1 Answer

0 votes
import random

st = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])

print(random.choice(tuple(st)))
print(random.choice(tuple(st)))
print(random.choice(tuple(st)))




'''
run:

2
7
8

'''

 



answered Aug 26, 2021 by avibootz
...