I'm having the following function which picks results from a results.txt file and displays it to the user, the first row comes out nicely but the rest of the results are not well-aligned. I'm not sure what's causing this. here's the function
def show_result():
'''prints the score list'''
file_exist()
print_whole_list = []
print("Results")
print("*"*41)
result = open("results.txt","r")
res = result.readlines()
print("Name: Lap1: Lap2: Lap3: In total: Average:")
for i in res:
temp_list = i.split(";")
total = int(temp_list[1]) + int(temp_list[2]) + int(temp_list[3])
average = int(total) / 3.0
average = round(average, 2)
temp_list.insert(4, total)
temp_list.insert(5, average)
print_whole_list.extend(temp_list)
for row in print_whole_list:
print("{0:{width}}".format(row, width=10), end=' ')
result.close()
The records in the text file:
Kembos;23;43;23;
Moses;42;51;43;
Ben;43;23;21;