i would like to generate random numbers and write them to a .txt file.
The range is : str(random.randint(0,10))
Before it generates me a random number my code should first check the .txt file. In this text file are already written down some random numbers. If the random number already exists it should generate me a new one and add it to my .txt file.
randomTxt = './random.txt'
def checkRandomNumberExists(value):
with open(randomTxt, 'a+') as random:
genRandom = str(random.randint(1,10))
if value in random:
random.write(genRandom)
random.write('\n')
I quess i am on the wrong way. Can anyone please help me. Thank you in advance