samedi 27 juillet 2019

For LOOP and random choice prints one string from a list

For some reason my list doesn't get printed completely, but only word by word each time I run the script.

import random

passwords = ['test', 'password', 'heslo', 'lol']

var = random.choice(passwords).split()

for word in var:
    print word

I wish the for loop to print my whole list in randomized order each time I run my script. Upon removing random.choice it works, but list is not randomized.




Aucun commentaire:

Enregistrer un commentaire