lundi 8 juillet 2019

Generate two different random number lists

I want to generate two differnt random number lists. The condition is the value of the first list index can con be equal to the second list value in the same index.

For example a=[5,6,7,5] and q=[2,7,3,5] in this case the value of the fourth index in list q is equal to the value in the same index in list a. I want to avoid this. I created list a as folllowing

import random
a=[]
b=list(range(1,7164))
for i in b:
   t=random.randint(1,20)
   a.append(t)

how to generate the second list with above condition?




Aucun commentaire:

Enregistrer un commentaire