From 013e9a2a59f2ab97f42910d2955a149693b93461 Mon Sep 17 00:00:00 2001 From: David Lawler Date: Wed, 2 Mar 2022 17:51:34 +1000 Subject: [PATCH] update 02-03-2022 --- .vscode/settings.json | 5 +++++ asked_questions_log.txt | 5 +++++ main.py | 6 ++---- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json 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)