def roll(M=100,T=100,N=6):
trails=[]
N_plus_1=N+1
for m in range(M):
collection=[random.randrange(1,N_plus_1)]
while [sum(collection)<T]:
collection.append(random.randrange(1,N_plus_1))
trials.append(len(collection))
return sum(trials)/len(trials)
why the roll function below keeps running forever and ddoesnt produce an answer. However, if i removes the square brackets from the while loop condition, then the roll function works just fine?