vendredi 17 mars 2017

Change character positions based on a string | python

Change character positions based on a string

Example:

import random

>>> name = "HelloWorld!"
>>> ''.join(random.sample(name,len(name)))
'HdWlllre!oo'
>>> ''.join(random.sample(name,len(name)))
'lol!dHrWeol'
>>> ''.join(random.sample(name,len(name)))
'ooHWl!derll'




Aucun commentaire:

Enregistrer un commentaire