Skip to content

Open the file mbox-short.txt and read it line by line. When you find a line that starts with 'From ' like the following line: From [email protected] Sat Jan 5 09:14:16 2008 You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who sent the message). Then print out a c…

Notifications You must be signed in to change notification settings

Kannupriyasingh/startswith-keyword-in-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

fname = input("Enter file name: ") #if len(fname) < 1 : fname = "mbox-short.txt"

fh = open(fname) count = 0

for line in fh: line=line.rstrip() if line.startswith("From "): r=line.split() print(r[1]) count=count+1 else: continue print("There were", count, "lines in the file with From as the first word")

About

Open the file mbox-short.txt and read it line by line. When you find a line that starts with 'From ' like the following line: From [email protected] Sat Jan 5 09:14:16 2008 You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who sent the message). Then print out a c…

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published