Skip to content

Instantly share code, notes, and snippets.

View Sasaki27's full-sized avatar
💜

saaki Sasaki27

💜
View GitHub Profile
@MichelleDalalJian
MichelleDalalJian / py4e_ex_07_02
Created October 7, 2017 12:52
7.2 Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: X-DSPAM-Confidence: 0.8475 Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output as shown below. Do not use the sum() function or …
# Use the file name mbox-short.txt as the file name
fname = input("Enter file name: ")
fhand = open(fname)
count = 0
for line in fhand:
if line.startswith("X-DSPAM-Confidence:") :
count = count + 1
total = 0