elements = ['why','where','what','who','when','how']
for x in range(5):
length=(random.randint(1,5))
whatever=""
for y in range(1,length):
whatever += elements[random.randint(0,5)]
print whatever
I'm trying to get the above code to print and combine the elements from the list into random strings that consist of 1 to 4 syllables. Right now its printing a syllable at a time and then joining them together. After the string reaches 4 syllables, it restarts and does the process again.
This is what it prints:
why
whywhen
whywhenwhere
how
howwhy
howwhywhy
what
whatwhen
whatwhenhow
whatwhenhowwhen
Aucun commentaire:
Enregistrer un commentaire