lundi 19 avril 2021

Replace comma-separated element positions inside Python text

I'm trying to find a comma-separated value inside the text and change the position randomly. For example

 Good morning. I am James. The weather is very nice today. I ate apples, bananas, milk, sandwich this morning. 

And my favorite things are movies, music, read books. And my total assets are $1,555,555,`555.

In the above string, search for /apple, banana, milk, sandwich / movie, music, reading/ and change the location at random. Exclude the number ($1,555,555,555) here. So finally

Good morning. I am James. The weather is very nice today. I ate bananas, apples, sandwiches, milk this morning.

And my favorite things are music, movies, read books. And my total assets are $1,555,555,555.

I want to change it like this. The elements should change randomly.




Aucun commentaire:

Enregistrer un commentaire