samedi 24 avril 2021

{python} Can someone explain this code to me (random numbers)

im still fairly new to python im wondering what this code does

    import random
    import string
    chars = string.digits
    random =  ''.join(choice(chars) for _ in range(4))

i know it makes a 4 digit random number but i want to know how it works with the ''.join(choice(chars) for _ in range(4)) and what string.digits means!

Thanks




Aucun commentaire:

Enregistrer un commentaire