diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e555942 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.linting.pylintEnabled": false, + "python.linting.enabled": true, + "python.linting.mypyEnabled": true +} \ No newline at end of file diff --git a/asked_questions_log.txt b/asked_questions_log.txt index e69de29..b5f39c6 100644 --- a/asked_questions_log.txt +++ b/asked_questions_log.txt @@ -0,0 +1,5 @@ + +today +today +weather +test \ No newline at end of file diff --git a/main.py b/main.py index 9921d8a..da01f31 100644 --- a/main.py +++ b/main.py @@ -17,6 +17,8 @@ def most_likely(userQuestion): mostLikelyIndex = likelihoodScore.index(max(likelihoodScore)) mostLikely = aList[mostLikelyIndex] + fileObject.close() + return mostLikely def main(): @@ -29,10 +31,6 @@ def main(): print ("I think that you asked " + "'" + (likelyQuestion['question']) + "'" + " and conclude that the answer is " + "'" + (likelyQuestion['answer']) + "'.\n") # Open the file in append & read mode ('a+') with open("asked_questions_log.txt", "a+") as file_object: - file_object.seek(0) # Move read cursor to the start of file. - data = file_object.read(100) - if len(data) > 0 : - # Append text at the end of file file_object.write("\n") file_object.write(userQuestion)