mardi 29 octobre 2019

How to generate certain length Credit Card number with prefix?

Trying to generate a certain length credit card number with a prefix given.

    while len(str(cc_number)) < (len(str(length)) - 1):
        digit = str(random.randrange(0, 9))
        cc_number = str(cc_number) + str((digit))
        return cc_number

I'm expecting to get say 16 digits long number with a variable size prefix given. How do i make this piece of code generate a right size string of numbers? This code by the way only concatenates 1 random digit to the end of the string... So i expect to get '4349578451278456', but the actual output is '41'




Aucun commentaire:

Enregistrer un commentaire