import sys if __name__ == '__main__': werAv = 0 sum = 0 lineCount = 0 with open('wer.txt','r+') as werOut, \ open('werFinish.txt','w+') as werF: for line in werOut: num = float(line) sum += num lineCount += 1 werAv = (sum / lineCount) * 100 werF.write(f'{werAv:.5f}\n')