Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- greetings = ["Hello", "What's up?", "Howdy!"]
- goodbyes = ["Bye!", "Goodbye!", "See you soon!"]
- keywords = ["music", "pet", "book"]
- responses = ["music is ok!", "pets are ok!", "books are ok!"]
- print("Bot: " + random.choice(greetings))
- while (1):
- text = input("Say sth (or type bye to quit): ").lower()
- if (text == "bye"):
- break
- exists = False
- for index in range(len(keywords)):
- if (keywords[index] in text):
- print("Bot: " + responses[index])
- exists = True
- if (exists == False):
- newKeyword = input("I'm not sure how to respond... Type keyword: ")
- keywords.append(newKeyword)
- newResponse = input("How I should respond to " + newKeyword + "? ")
- responses.append(newResponse)
- print(random.choice(goodbyes))
Add Comment
Please, Sign In to add comment