samedi 18 juin 2016

Generate a random number from a list, not including one of the numbers

I am trying to create a list of sequential integers from 0 to n, then after picking a randon integer from that list, generate another random integer from the same list that doesn't include the integer previously generated.

n = 10

a = np.arange(1,n) #Creating my initial list

for b=np.random.choice(a): #Generating my first random number
    c=np.random.choice(np.arange(1,b)) or np.random.choice(np.arange(b+1,n))

I know that this won't work because my for loop is pretty iffy. I haven't used python in a long time and I am just starting a project and getting myself back into it is proving to be a little tricky!




Aucun commentaire:

Enregistrer un commentaire