lundi 8 avril 2019

How to loop through a random function multiple times?

def a4():
    p = []
    for i in range(10):
        p.append(random.sample(x, 100))
    r = []
    for i in p:
        for j in i:
            r.append(j)
    return r

OUTPUT: [0.5202486543583558, 0.5202486543583558, 0.5202486543583558, 0.5202486543583558, 0.5202486543583558]

a1000 = []
for i in range(5):
    a4()
    a1000.append(statistics.mean(a4()))
print(a1000)

I tried to loop through the above defined function using for loop mentioned above but the function only runs once and all the loop results are basically the same. I want function to run each time through the loop. Could someone tell me why the function is only running once?? I appreciate your input.




Aucun commentaire:

Enregistrer un commentaire