Skip to content
Permalink
Browse files
Update greeting.py
Comments added to explain why certain steps were taken
  • Loading branch information
mirikip committed Nov 28, 2018
1 parent 73e3d29 commit 030e4890537daf6d7aceb83e70535ede064d72a7
Showing 1 changed file with 13 additions and 10 deletions.
@@ -1,14 +1,17 @@
import random
import time
import random #Random function imported and used to return a random value from a selection
#dictionary created so random responses are given based on the users input
greetings = {"hello": ["Hey how are you?", "Whats up?", "Welcome"], "hey": ["Welcome", "How may i help you?"],
"sup": ["Wagwan bro", "Whats good?", "Welcome"], "hi": ["Hey how are you?", "Whats up?", "Welcome"]}
# While loop......
def respond(ck):
if ck in greetings:
response = random.choice(greetings[ck])
print(response)
else:
print(".......Sorry i did not quite get that")
"sup": ["Wagwan bro", "Whats good?", "Welcome"]}


def respond(message):
if message in greetings:
response = random.choice(greetings[message])
#Prints a random greeting allocated with what the user input
#This is to provide viarety as well as cater to different users
print("Chatbot: " + response)
else:
print("Sorry i did not quite get that")

chat = input("You: ")
respond(chat)

0 comments on commit 030e489

Please sign in to comment.