I am struggling a bit here with saving the information from the random number generator to a text file.
My code is generating a random number in a certain range, for ever or until the program is terminated. I want to store those numbers in a txt file that I can later open and look at the results.
from random import randint
import time
with open('randnum.txt', 'w') as f:
f.write(""""I AM STRUGLING WITH WHAT GOES HERE"""")
def roll_many(n,x):
for i in range(x):
roll = randint(45000000,45999999)
print(roll)
roll_many(1,1)
time.sleep(1)
while True:
roll_many(1,1)
time.sleep(1)
"""THERE SHOULD ALSO BE SOMETHING HERE TO END THE WRITING?"""
Aucun commentaire:
Enregistrer un commentaire