mal = ["a","b","c","d","e","f","g"]
num_to_select = randint(1,4)
list_of_random_items = random.sample(mal , num_to_select)
first_random_item = list_of_random_items[0]
second_random_item = list_of_random_items[1]
print(second_random_item)
print(first_random_item)
I searched some questions here and tried to edit a bit but doesnt work.
I want to select random items for random times like;
python randomly chose the number 4
printed randomly 4 items from list
Thank you.
Aucun commentaire:
Enregistrer un commentaire