Please always post the full error text in future. Meanwhile I'll guess:
On 29/10/16 05:42, SONU KUMAR wrote: > fname = raw_input("Enter file name: ") > if len(fname) < 1 : fname = "mbox-short.txt" > fh = open(fname) > count = 0 > for line in fh: > line=line.rstrip missing parens means you reassign line to the method. > if not line.startswith("From"):continue The method does not have a startwith attribute. > lst=line.split() Nor a split method. > > print lst[1] > > count=count+1 > print "There were", count, "lines in the file with From as the first word" HTH -- 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