inFp = None
outFp = None
inFp = open('data.txt', 'r')
outFp = open('output.txt', 'w')
score = inFp.readlines()
score = list(map(float, score))
scoresum = 0
for i in score :
scoresum = scoresum + i
average = scoresum / len(score)
I'm wondering what to do from here.
You can't fix it many times.
You made a good code for calculating the total and average. If the problem is printing the results in the output.txt file, in the last line of the program,
print('total = {}\nMean = {}'.format(scoresum, average), file=outFp)
Try adding it.
© 2024 OneMinuteCode. All rights reserved.