lundi 13 février 2017

Python: random.choice not working with variable

Im using the following code:

E_ready = [E[i:i+n] for i in range(0, len(E), n)]
    for code in E_ready:
        letter = (random.choice(code))
        Code += letter
        print(Code)

and i have a list for every single letter i.e n = ['X','Y']. if the word is, for example: nod, it SHOULD take each letter then take a random element from each letters' respective list but it just prints the letter itself, it just prints the same word (nod). what can i do to fix this?




Aucun commentaire:

Enregistrer un commentaire