I am working on a school project where I have to generate a list of numbers with no repeats. The twist is I am not allowed to used random.sample() or random.shuffle(). I think I have found a way around it with my code except I get the error TypeError "argument of type 'type' not iterable. I have not been able to get around this so I need some help. Thanks for the help Here is the code:
import random
lis=[]
for i in range(5):
rand=random.randint(1,10)
if rand not in list: lis.append(rand)
print (lis)
Aucun commentaire:
Enregistrer un commentaire