From c548affed69ce5dd67bc30c5a6306340d4da47f6 Mon Sep 17 00:00:00 2001 From: Luis Gallegos <66088319+luisito362@users.noreply.github.com> Date: Sat, 6 Apr 2024 09:57:27 +0800 Subject: [PATCH] Update wk7 - assignment 7.2.py --- wk7 - assignment 7.2.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/wk7 - assignment 7.2.py b/wk7 - assignment 7.2.py index 608007e..60405eb 100644 --- a/wk7 - assignment 7.2.py +++ b/wk7 - assignment 7.2.py @@ -7,17 +7,14 @@ # Use the file name mbox-short.txt as the file name -fname = input("Enter file name: ") -fh = open(fname) -sum = 0.0 count = 0 - +big = 0 +big = float(big) +fname = input("ENTER FILE NAME :") +fh = open(fname) for line in fh: - if not line.startswith("X-DSPAM-Confidence:") : - continue - else: - sum = sum + float(line[20:]) - count = count + 1 - -print("Average spam confidence:", sum/count) - + if line.startswith("X-DSPAM-Confidence:") : + a=float(line[20:26]) + big = big+a + count = count + 1 +print('Average spam confidence:',big/count)