A file called input.
john 9 7 6 7 4 3 9 5(double space)76 54 53 77 65(double space)4 45 45


def main():

fin = open ("input", "r")

line = fin.readline()
x = line.split(" ")

a= (int (x [1])+ int (x [2]) +int (x [3])+ int (x [4]) +int (x [5])+ int (x [6]) +int (x [7])+ int (x [8]))/(8)*(10)
b= (int (x [9])+ int (x [10]) +int (x [11])+ int (x [12]))/(4)
c= ((int (x [13])+ int (x [14]))/2)
d= (int (x [15]))
average = a+b+c+d

print average


Before the extra space was put in on the few places on the input this program averaged the numbers fine then the double space was put in in a few spots and now its giving an error does anyone know how to fix it and ignore the doubles space and just go to the integer like its suppose to.
b= (int (x [9])+ int (x [10]) +int (x [11])+ int (x [12]))/(4)
ValueError: invalid literal for int() with base 10: ''
This is the error im getting

Edited 6 Years Ago by sss33: n/a

This question has already been answered. Start a new discussion instead.