Skip to content
Permalink
Browse files
Add starting files
  • Loading branch information
ab9797 committed Oct 7, 2020
1 parent 6e6c2dc commit 7e4728127e27ed147d01ebba493cf3622a61d918
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
@@ -0,0 +1,15 @@
from random import choice as randomChoice

def isGreeting(userInput):
"""Returns Boolean indicating if user input was a greering."""
greetings = ["hello", "hi"]
for word in greetings:
if word in userInput:
return True
return False

def respond():
"""Prints a response to user greeting"""
responses = ["alright", "hiya"]
out = randomChoice(responses)
print(out)
12 Name.py
@@ -0,0 +1,12 @@
from random import choice as randomChoice

def giveName():
"""Chooses a random name for chatbot"""
names = ["chatbot3000", "bob"]
out = randomChoice(names)
print("My name is " + out)

def askName():
"""Asks user their name and greets"""
userName = input("What is your name? ")
print("Nice to meet you " + userName)
15 main.py
@@ -0,0 +1,15 @@
from Greetings import isGreeting, respond
from Name import askName, giveName

# Loop below runs my very basic chatbot

while True:
fromUser = input("%%% ")
if fromUser in ["exit", "quit"]:
break
elif isGreeting(fromUser):
respond()
else:
giveName()
askName()

0 comments on commit 7e47281

Please sign in to comment.