tmp = []
while len(tmp) == 0:
for i in range(0,385):
# Multiplying by 100 in order to remove the decimal point
if randint(0,10000) < chance*100:
tmp.append(i)
return tmp
This is the code I'm currently using to help clear things up. The output will be something like this.
[34, 234, 243, 321]
My current solution is very inefficient. I tried this:
sample(range(0,385), math.ceil(chance*3.85))
But it doesn't produce the same effect. Also if you could tell me the name of what this is called that would be great.
Aucun commentaire:
Enregistrer un commentaire