You seem to have a misunderstanding of what the arguments to
split
and
rstrip()
do. In both cases the argument supplies a
set of characters that the method applies to the string. For example:
>>> str='From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008'
>>> x = str.split('From')
>>> x
['', ' stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008']
>>>
That's not what you've been asked for at all. On the other hand
>>> str=
'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008'
>>> x = str.split()
>>> x
['From', 'stephen.marquard@uct.ac.za', 'Sat', 'Jan', '5', '09:14:16', '2008']
So a simpler solution would be
for line in fh:
x = line.split()
if x[0] == 'From':
print(x[1])
count += 1