[Tutor] Mailbox

ltc.hotspot at gmail.com ltc.hotspot at gmail.com
Wed Jul 29 23:55:34 CEST 2015


Hi Everyone:






I have a second and unrelated question:





I tried to work backward  to see if there is a logic error associated with a variable is being skipped over:




#top of code, initialize variable
output_list = ["default"]




#rest of code
If you get at the end





print output_list





['default']





Raw Data File:




count = 0
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
for line in fname:
    line = line.strip()
    if not line.startswith('From '): continue
    line = line.split()
count = count + 1
print len(line)
fh = open(fname)
print "There were", count, "lines in the file with From as the first word"





Sample data file at  http://www.pythonlearn.com/code/mbox-short.txt





Desired Output:




stephen.marquard at uct.ac.za
louis at media.berkeley.edu
zqian at umich.edu
rjlowe at iupui.edu
zqian at umich.edu
rjlowe at iupui.edu





Thanks,

Hal


Sent from Surface





From: Phu Sam
Sent: ‎Wednesday‎, ‎July‎ ‎29‎, ‎2015 ‎1‎:‎06‎ ‎PM
To: Ltc Hotspot





































_______________________________________________
Baypiggies mailing list
Baypiggies at python.org
To change your subscription options or unsubscribe:
https://mail.python.org/mailman/listinfo/baypiggies


More information about the Tutor mailing list