jeudi 17 juin 2021

How to make the program choose a random string from a list and not use it again throughout the entire program in python?

I am making a program that will need to print a lot of hints and in order to avoid repetition and make it more interesting, I want the program to pick those hints randomly from lists that I am going to make. I also want to remove a hint after being used so the program doesn't use it again in a place that it won't need to. Can someone show an example of that on this code:

import random

foo = ['a', 'b', 'c', 'd', 'e']
print(random.choice(foo))



Aucun commentaire:

Enregistrer un commentaire