From 9e3170c9a96c91c32972d00d8190fb1c9c919d75 Mon Sep 17 00:00:00 2001 From: Jasper Dahil Date: Fri, 3 Nov 2017 09:53:34 +0000 Subject: [PATCH] placed taking unwanted characters into determinUserInput so the sentence is left with no , . ? ! --- Get_Functions.py | 10 +--------- determineUserInput.py | 9 +++++++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Get_Functions.py b/Get_Functions.py index e5c8200..417a079 100644 --- a/Get_Functions.py +++ b/Get_Functions.py @@ -14,15 +14,7 @@ randomStuff = ["Cherophobia is the fear of fun","A flock of crows is called a mu def getName(sentence): """get the name of the user from the inputed sentence""" - #first - getting rid of unwanted chars - unwantedChar = [".","'","!","?",","] - newSentence = "" - for char in sentence: - if char not in unwantedChar: - newSentence = newSentence + char - newSentence = newSentence.lower() # makes all letters into lowercase - much easier and more efficient - - userWords = newSentence.split() #the sentence is split up into words and put into a list + userWords = sentence.split() #the sentence is split up into words and put into a list # ways of introduction: # "Hello, my name is ___" diff --git a/determineUserInput.py b/determineUserInput.py index 051d6b5..05c130b 100644 --- a/determineUserInput.py +++ b/determineUserInput.py @@ -9,12 +9,17 @@ def determineUserInput(sentence): response = "" sentence = sentence.lower() sentenceParse = sentence.split() - + #first - getting rid of unwanted chars + unwantedChar = [".","'","!","?",","] + newSentence = "" + for char in unwantedChar: + sentence.replace(char,"") + if sentenceParse[0] in questionStarters: # ------------- execute the "what is" code here --------------- response = respondQuestion(sentence), 2 elif sentenceParse[0] in greetings: response = getName(sentence), 1 - elif sentence[0] in "abcd": + elif sentenceParse[0] in "abcd": response = sentence, 3 else: response = sentence, 0