我目前正在尝试在 python 中编写一个代码,如果您对它的回复在可能的答案列表中,它将回复您。程序示例如下。
def responce():
greetings = ["Hello","Hi","Nice to see you!","Greetings","How's it going?","How are you doing?","What's new?","How's your day going?","Hey!"]
print("\n")
reply = input(": ")
lenrep = len(reply)
tempstore = []
for i in range(0,lenrep):
tempstore.append(i)
z = 0
while z < 9:
tempgreet = greetings[z]
if tempstore.upper() == tempgreet.upper():
reply = ""
tempstore = []
temprandno = random.randint(0,2)
addon = ["what do you want to know?", "what do you want to talk about?", " "]
addontext = addon[temprandno]
text(greet(), …Run Code Online (Sandbox Code Playgroud)