Answers for "grab 3 itemsfrom list randomly"

9

print random string from list python

import random

list = ["Item 1", "Item 2", "Item 3"]			# List
item = random.choice(list)						# Chooses from list
print(item)					# Prints choice

# From stackoverflow
# Tried and tested method
Posted by: Guest on May-05-2020
0

python random select no replace

import random

aList = [20, 40, 80, 100, 120]
print ("choosing 3 random items from a list using random.sample() function")
sampled_list = random.sample(aList, 3)
print(sampled_list)
Posted by: Guest on November-02-2020

Code answers related to "grab 3 itemsfrom list randomly"

Python Answers by Framework

Browse Popular Code Answers by Language