lundi 20 septembre 2021

How to make random.choice in a for loop give the same output every time

I am reusing a code written by someone else. It has the following line included:

 df = (random.choice(x) for i in repeat(0))

However, because there is no random.seed, the output is different every time I rerun it, which makes sense.

I tried to fix this with random.Random(500).choice(x), but since it's a for loop, it will then give me the same value for every iteration, which is not what I want.

Does anyone know how I make this pseudo-random? Thanks!




Aucun commentaire:

Enregistrer un commentaire