mardi 6 février 2018

Joining Strings Together Randomly in Python

I'm looking for the words in the list to be joined together in different combinations, but it's only returning single word results. I'm looking for strings like 'whywho' 'whatwhywhen' 'howwhywhatwho' etc.

import random, sys
words = ['why', 'who', 'what', 'why', 'when', 'how']

for i in range(100):
    print ''.join(random.choice(words[:randint(1, 4)]))




Aucun commentaire:

Enregistrer un commentaire