Python Forum
Generate only one random number for many tries - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Generate only one random number for many tries (/thread-25394.html)



Generate only one random number for many tries - Bhavika - Mar-29-2020

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.


RE: Generate only one random number for many tries - ndc85430 - Mar-29-2020

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.


RE: Generate only one random number for many tries - Bhavika - Mar-29-2020

Thank you
I got the expected output after using
import random
random.seed(1000)
print(random.random)