Home > Net >  how to reorganize a list's members?
how to reorganize a list's members?

Time:11-19

I have a list that I want to join it together as a string but I don't want it to be in the same order as the list. it gives me : "sdfg123" but I want it to provide me with the members in different orders each time that I run the program.

~ password=['s','d','f','g','1','2','3']

join_pass=''.join(password)

print(join_pass) ~

CodePudding user response:

You could try to shuffle the list before joining:

import random
password=['s','d','f','g','1','2','3']
random.shuffle(password)
join_pass = ''.join(password)

print(join_pass)
  • Related