I have a list of 30 strings. I want to use the choice method of the random module and generate a new string from the list they are stored in. I don't want to repeat any strings and I want to print all the unique strings once. I am trying to make a chat bot but I can only get 1 string to print over and over every time I run the program
print("you are speaking with Donald Trump. If you wish to finish your conversation at any time, type good bye") greetings = ["hello", "hey", "what's up ?", "how is it going?", ] #phrase_list = ["hello", "the wisdom you seek is inside you", "questions are more important than answers"] random_greeting = random.choice(greetings)
print(random_greeting)
open_article = open(filePath, encoding= "utf8")
read_article = open_article.read()
toks = read_article.split('"')
random_tok = random.choice(toks)
conversation_length = 0
responses = ''
while True: #getting stuck in infinite loops get out and make interative
user_response = input(" ")
if user_response != "" or user_response != "good bye":
responses = responses + user_response
conversation_length = conversation_length + 1
while conversation_length < 31:
print(random_tok)
if conversation_length >= 31:
print("bye bye")
Aucun commentaire:
Enregistrer un commentaire