Python Forum

Full Version: Generate only one random number for many tries
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Normally we use
import random
print(random.randint(1000, 9999)
To generate a number in the range. But I want a number which we generate at random but can be used for how many times ever we run the code.
What do you mean? Do you want to generate the same value every time you run the code, or something else? If that is what you mean, call random.seed to set the seed to whatever constant value you want.
Thank you
I got the expected output after using
import random
random.seed(1000)
print(random.random)