Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python random.sample

#random.sample takes a list and randomly selects k items from it
new_list = random.sample(list, k)
#for example:
nums = [1, 2, 3, 4, 5]
sample_nums = random.sample(nums, 3)
print(sample_nums) # 2, 5, 1
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Python
ADD COMMENT
Topic
Name
2+7 =