import time import sys t0=time.clock() a=[] f=open("in20_8.txt",'r') w=open("out_r8_sec20_8.txt",'w') count=0 for row in f: a=row h=0 for i in a: if i=='A' or i=='P'or i=='R'or i=='O' or i=='D': h=h+1 if i=='B': h=h+1 w.write("No. of Holes in the text: "+str(h)) t1=time.clock() t2=t1-t0 f.close() memory=sys.getsizeof(a)+sys.getsizeof(f)+sys.getsizeof(w)+sys.getsizeof(t1)+sys.getsizeof(t2) w.write("\nExecution Time:"+str(t2)) w.write("\nMemory Used:"+str(memory)) w.close()