I have read that the random
module in Python uses the previously generated value as the seed except for the first time where it uses the system time.
(https://stackoverflow.com/a/22639752/11455105, https://pynative.com/python-random-seed/)
If this is true, why don't I get the same value when I explicitly set the previously generated value as the new seed like this:
random.seed(random.randint(1, 100))
The same doesn't work for the random.random()
method either.
>>> import random
>>> random.seed(20)
>>> random.randint(1,100)
93
>>> random.randint(1,100)
88
>>> random.seed(20)
>>> random.randint(1,100)
93
>>> random.randint(1,100)
88
>>> random.seed(20)
>>> random.seed(random.randint(1,100))
>>> random.randint(1,100)
64
Why didn't the last randint()
call not give 88?
Thanks in Advance!