lundi 3 décembre 2018

calling a random variable from set of multiple variables once PYTHON

Hello there I am now about to learn how you can call a random variable multiple times without those variables doubling itself.

The logic I got for now goes like this:

get a len of the array the variables are stored in, random.randint(1, len(the_aray))

then print a variables place in the array and question for running it again

if yes, store previous result of random.randint then 

if random.randint in previous_results_board, go again..

if not, print the result out

for len var_array = len previous_results_board print 

"this is the end of this program" and wait for input, 

after typing/pressing whatever the script terminates.

is there some more "optimized" version of it? and if not, how do I solve the problem of storing previous results in an array?




Aucun commentaire:

Enregistrer un commentaire