I was trying to write the output of a loop on a file. The problem is the writing repeats for each loop.
prev_line = "" while line: Total = 0 fields = line.split() N = len(fields) name = fields #sum each 5 fields over the raw: for step in range (6, N, 5): Total2 = 0 for i in range (step-5, step, 1): Total2 += float(fields[i]) # do something prev_line = Total2 print_grades(name, "%d" % (prev_line))
The output looks like this:
but I want it to be
Big-man 215 285 232 ....
would you please help me with this?