I have written a program which asks a user how they want their data to be sorted. One way the data could be sorted is by the average of students scores from highest to lowest. However, I am having a problem with this as the program outputs all 3 scores for the student instead of the average of these 3 scores. The program can sort the order of highest to lowest but it shows all 3 scores instead of the average score. How could I fix this problem?
Asked
Active
Viewed 97 times
-2
-
1You only compute the average inside of a `ValueErrorr` exception, which is backwards (you should compute the average after the for completes. You show entries being printed for Emily and etc... but your code has no prints at all. In fact, you don't even use the result of `AverageScore`... so where is it coming from?! – tdelaney Feb 24 '15 at 21:22
2 Answers
1
How about this?
from numpy import average
a='1,2,3'
average( [int(n) for n in a.split(',') ] )

Pat
- 353
- 1
- 4
- 15
0
You are returning the entire line_avg list. You just need to return the averages along with, not all of the grades

Wickie Lee
- 109
- 1
- 7
-
I think that in the real code, its supposed to be computing one list item per student. But the code we've been given is too messed up to be sure. – tdelaney Feb 24 '15 at 21:24
-