vendredi 4 novembre 2016

How to randomly change n characters in a string

I am wondering how to randomly change n characters in a string, e.g.

orig = 'hello'

mod = 'halle'

that I want to randomly select two positions (orig[1] and orig[4]) in the string, and replace the chars in the positions of the original string (hello) with randomly selected chars (a and e here), results in a new string halle.




Aucun commentaire:

Enregistrer un commentaire