vendredi 21 février 2020

Make Python Generate Number Between 0 and 1000 all with 4 digits?

Basically I have the following code:

import random

list01 = list(range(0, 3334))
list02 = list(range(3334, 6667))
list03 = list(range(6666, 10000))

random.shuffle(list01)
random.shuffle(list02)
random.shuffle(list03)

text_file = open("Misc.txt", "w")

while list03:
    text_file.write("\\" + str(list01.pop()) + "\\\\" + str(list02.pop())+"\\\\" + str(list03.pop())+"\\\n")

text_file.close()

But I need to generate the first thousand with 4 digits as well, is there anyway I can do it in Python?




Aucun commentaire:

Enregistrer un commentaire