From 0653cbf0b1a7fb8e56cd6781ef9c83572298fb3c Mon Sep 17 00:00:00 2001 From: Jasper Dahil Date: Thu, 2 Nov 2017 09:08:35 +0000 Subject: [PATCH] the code now works with dealing with question that has no spaces --- __pycache__/Get_Functions.cpython-36.pyc | Bin 2172 -> 2172 bytes detemineUserInput.py | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/__pycache__/Get_Functions.cpython-36.pyc b/__pycache__/Get_Functions.cpython-36.pyc index 1de00e48f712c7061365b000a6beac5b34795fd7..3ae3b4cb22334f9af3f99ee13661dac2b5788650 100644 GIT binary patch delta 16 Xcmew(@JE2%n3tEU;P$VL?4=w4Gy?_k delta 16 Xcmew(@JE2%n3tDp)%Kqo*-JS9G`t1| diff --git a/detemineUserInput.py b/detemineUserInput.py index 7ef7253..f243f6a 100644 --- a/detemineUserInput.py +++ b/detemineUserInput.py @@ -22,6 +22,7 @@ def reformatSentence(sentence, operatorType): """reformats the sentence so we're left with just the equation""" equation = "" char = "" + if operatorType == "symbols": # this part runs if the equation is using + - * / for i in sentence: if i not in "what is ": @@ -36,7 +37,7 @@ def reformatSentence(sentence, operatorType): if i == 'what' or i == 'is': continue else: - equation = equation + " " + i + equation = equation + i equationParce = equation.split() equation = "" for part in equationParce: @@ -61,7 +62,21 @@ def executeWhatFunction(sentence): for i in sentence: if i in numberList: #checks whether the question involves numbers, like 1 + 1 numberQuestion = True - + + #add spaces to the sentence + addedSpaceSentence = "" + for i in sentence: + if i not in "what is": + if i in numberList or i in operatorList[0:4]: + addedSpaceSentence = addedSpaceSentence + i + " " + elif i == " ": + continue + else: + addedSpaceSentence = addedSpaceSentence + i + else: + addedSpaceSentence = addedSpaceSentence + i + sentence = addedSpaceSentence + if numberQuestion == True: operatorType = "" sentenceParce = sentence.split()