Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Update greeting.py
Comments added to explain why certain steps were taken
- Loading branch information
Showing
1 changed file
with
13 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |