We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 96c57f6 commit 5bb8a9eCopy full SHA for 5bb8a9e
Assignment_8_5.py
@@ -0,0 +1,20 @@
1
+'''Open the file mbox-short.txt & read it line by line.
2
+When you find a line that starts with From like the following line:
3
+ From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008
4
+You will parse the From line using split() & print out the second word in the line (entire address).
5
+Then print out a count and end.
6
+FILE: mbox-short.txt
7
+WEB LINK: http://www.py4e.com/code3/mbox-short.txt'''
8
+
9
+name = input('Enter the file name: ')
10
+file = open(name)
11
+word = []
12
+count = 0
13
+for line in file:
14
+ line = line.rstrip()
15
+ if line.startswith('From'):
16
+ count += 1
17
+ word = line.split()
18
+ print(word[1])
19
20
+print('There were',count,'lines in the file with From as the first word')
0 commit comments