Re: [Tutor] why it is showing attribute error in line7

2016-10-29 Thread Steven D'Aprano
Hello, and welcome! Please always post the FULL traceback. Python gives you lots of information to debug problems, so you don't have to guess, but when you throw that information away, we have to guess. My guess follows below: On Fri, Oct 28, 2016 at 09:42:35PM -0700, SONU KUMAR wrote: >

Re: [Tutor] why it is showing attribute error in line7

2016-10-29 Thread Alan Gauld via Tutor
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

[Tutor] why it is showing attribute error in line7

2016-10-29 Thread SONU KUMAR
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 if not line.startswith("From"):continue lst=line.split() print lst[1] count=count+1 print "There were", count, "lines in the file with