Archived
1
0
Fork 0
This repository has been archived on 2024-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
PY4E/Assignment 8.5/main.py

24 lines
577 B
Python
Raw Normal View History

2021-09-08 10:33:48 -05:00
fname = input("Enter file name: ")
if len(fname) < 1:
fname = "mbox-short.txt"
fh = open(fname)
count = 0
for line in fh:
line = line.split()
# Check Length, Count from and print email
if len(line) > 0:
if line[0] == "From":
count = count + 1
print(line[1])
# Iterate over words in the line and if from print email
# for word in line:
# if word == "From":
# count = count + 1
# print(line[1])
print("There were", count, "lines in the file with From as the first word")