Print Highest, Average, Lowest score of a file
<p>I'm trying to print the highest, average, and lowest score of a file in python. But I keep getting error </p>

<pre><code>ValueError: invalid literal for int() with base 10.
</code></pre>

<p>My <em>results.txt</em> file looks like this:</p>

<pre><code>Johnny-8.65
Juan-9.12
Joseph-8.45
Stacey-7.81
Aideen-8.05
Zack-7.21
Aaron-8.31
</code></pre>

<p>And my code looks like this</p>

<pre><code>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))
</code></pre>

<p>Try this:</p>

<pre><code>scores={}
highest_score=0.0
highest=''
lowest_score=100.0
lowest=''
average=0.0
sums=0.0

files=open("results.txt","r").readlines()
for lines in files[0:]:
    line=lines.split("-")
    scores[line[0]]=line[1].strip()

for key,value in scores.items():
    if float(value)&lt;lowest_score:
        lowest_score=float(value)
        lowest=key

    if float(value)&gt;highest_score:
        highest_score=float(value)
        highest=key

    sums=sums+float(value)

print "highest score:",highest_score," of ",highest
print "lowest score:",lowest_score," of ",lowest
print "average: ",sums/len(scores)
</code></pre>

python max average data-type-conversion min