-2
遇到一些麻煩這個...新的隨機句話印在每次迭代
我能夠隨意創建一個句子與此代碼,但現在我要遍歷以使10個隨機句子。
import random, pprint
#Create first list of elements
elements1 = []
#Create second list of location descriptions
prepositionList = []
#Create second list of elements (same as first)
elements2 = []
#Randomly choose one entry from each list to make into sentence.
randomSentence = (random.choice(elements1) + ' ' + random.choice(prepositionList) + ' ' +
random.choice(elements2))
print(randomSentence)
我該如何打印10個不同的句子?
感謝
把它放在一個循環中。 –