I am very new to programming , I am trying to do task where I have to count the number of lines that are read until the total length of the lines is 1,000 characters and also it it doesn't count characters on any line that begins with a pound sign (#).
here is my code:
char,lines = 0,0
log = open('/tmp/new.txt','r')
for count,line in enumerate(log) :
if '#' not in line :
if char + len(line) < 1000 :
char += len(line)
lines += 1
when i execute its counting all lines including '#")
its prinitng 999 and 37 instead of 45. What mistake am i doing here ? Can some one please help?