On 30/07/15 22:17, ltc.hots...@gmail.com wrote:

fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt" # assign fname
fh=open(fname,'r') # Open a new file handle
for line in fh:
     print line
     if 'From' in line.split()[0] and '@' in line: sender = line.split()[1]
     fn.seek(0)
print sender

Questions: Why is the loop not repeating,

What makes you think so?
If you get an error(as I suspect) please post the entire error message.

I would expect a name error on the last line of the loop since there is no variable fn defined.

I don't know what you think the seek() is doing, but (assuming
you meant fh) it will reset the file to the first line each time
so you never finish the loop.

and where should I insert a split to remove 'Sat Jan 5:09:14:16 2008'

 From stephen.marqu...@uct.ac.za Sat Jan 5 09:14:16 2008 ← Mismatch

Splitting on whitespace will ensure the bit you want is
in the second element


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to