How to build a random story generator using python?
有一次卷福去吉米秀,俩人根据卷福随机想到的几个单词,大开脑洞,编了一个小品。
👇下面是金句赏析
“The crime scene has your butt written all over it.”
"You know one of the best parts about being a detective, is that I get to lock up criminals like you and go home to my children and my pet badger, and say this town needs an enema."
效果直接拉满。
这次尝试的story generator是让自己辅助我们完成这个工作。代码如下。
Generator 1:
import random
#list of books is stored in the list -'books'
books = ['Mother','Midnight Children','My experiments with truth']
#An item from the list 'books' is selected
#by random.choice()
print(random.choice(books))
Generator 2:
#Importing random module
import random
#Defining list of phrases which will help to build a story
Sentence_starte