mardi 6 février 2018

Is there way to randomize the join function in Python?

I'm using the join function to join words from a list into strings in Python. Is there a way to use the choice/random function to randomize the choices into multiple different strings?

For example, now it does:

In [44]: sentence = ['this','is','a','sentence']
    ...: >>> ''.join(sentence)
    ...: 
Out[44]: 'thisisasentence'

And I would like to get:

'thissentence'
'isathis'
'thisissentence'
'isathis'




Aucun commentaire:

Enregistrer un commentaire