I created code for tracking tests for my students, the code works but the formatting is off. Instead of even columns they are displayed incorrectly. The code I have is:
def main():
mytests = open('test.txt','r')
count = 0
total = 0
print('Reading six tests and scores')
print()
print('TEST SCORE')
for line in mytests:
name = line.rstrip('\n')
score = int(mytests.readline())
print(name,' ', score)
count += 1
total += score
mytests.close()
print('Average: ',format(total/count,'.1f'))
main()
The output looks like: Reading six tests and scores
TEST SCORE
History 98
Math 89
Geology 78
Space 78
PE 90
Religion 75
Average: 84.7
Does anybody have any ideas on how I can format the score column to be in alignment?