jeudi 7 septembre 2017

Could not generate the 8 digit alphabet random number using Python [on hold]

I have an issue.I want to generate 8 digit only alphabet random number using python but I am getting only one character after generation. I am explaining my code below.

import random
    alphabet = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    pw_length = 8
    paword = ''
    for i in range(pw_length):
        next_index = random.randrange(len(alphabet))
        pword = paword + alphabet[next_index]

    print(pword) 

Here I am getting the output like C . I need to generate only alphabet 8 digit random number. Please help.




Aucun commentaire:

Enregistrer un commentaire