Python 3 - using multiple times choice -


how use 'choice' multiple times in single command line. want use command 'choice' following -

>>> l ['9', '10', '1', '2', '3'] >>> choice(l) '2' >>> choice(l)*3 '222' 

i need generate 3 different values l , not 3 times same number.

if values can same run random.choice() 3 times (in loop, example).

but if need different, use random.sample() instead , have pick 3 values that different you:

random.sample(l, 3) 

using random.choice() repeatedly can lead values being picked more once, random.sample() ensure 3 values picked unique.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -