I'm trying to print the highest, average, and lowest score of a file in python. But I keep getting error
ValueError: invalid literal for int() with base 10.
My results.txt file looks like this:
Johnny-8.65
Juan-9.12
Joseph-8.45
Stacey-7.81
Aideen-8.05
Zack-7.21
Aaron-8.31
And my code looks like this
func1={}
with open('results.txt','r') as f:
for line in f:
name,value=line.split('-')
value=float(value)
if name in func1.keys():
func1[name].append(value)
else:
func1[name]=[value]
#compute average:
for name in func1:
average=sum(func1[name])/len(func1[name])
print("{} : {}".format(name,average))