vendredi 15 juillet 2022

Randomized Strings + Digits [4 formats]

    for i in range(num):
    code = "".join(random.choices(
        string.ascii_uppercase + string.digits,
        k = 16
    ))

So this is a code I made which randomly generates 16 characters, I would like for the output to also be in different formats. These are all the formats:

XX-XXXX-XXXX-XXXX-XXXX -- [18 chars] Letters + Numbers [All capital]
XXX XXX XXXX -- [10 chars] Only Numbers
XXXX XXXX XXXX -- [12 chars] Letters + Numbers [All Capital]
XXXXXXXXXXXXXXXX -- [16 chars] Letters + Numbers [All Capital]

I'd like it to do 1 of the 4 randomly [as well as the one I made] The problem I'm having is adding the "-"'s for the first one. It doesn't apply to the last two though, but for those ones there will be a space as indicated.




Aucun commentaire:

Enregistrer un commentaire