mercredi 8 avril 2020

how to format decimals in an output?(random library)

hello so I want to print a random generated number from 0-1000000 and format it so it is always 6 digits. Say the random number generated is 90000 I want it to print 090000, I am not very good at formatting but this is what I have:

import random
ok = random.randrange(0000000,999999)
if ok < int(100000):
  format(ok, 0)
print(ok)

Let me know how to format so it is always 6 digits even if its 000001 etc! thank you




Aucun commentaire:

Enregistrer un commentaire