Can you explain your logic? I don’t understand what any of your code is doing.
I second @galencolin. I don’t understand your code either.
You can create an array of length 8 (since 9, 10 and 11 don’t matter). Initialize all values to 0. I will denote the problem number with
p and score with
p > 8, don’t do anything. Else
array[p-1] = max(array[p-1], s) (Assumung 0-based indexing).
total = 0
total += sum(array)
Then all you need to do is
It takes the first problem number§ and compares it to the other problem numbers entered.
If the index of the list ‘stats’ in the second 'for loop ’ is 0 (k == l) then y is added to the score as long as the problem number§ is between 1 to 8. After the 0th index, if the remaining question numbers are between 9 to 11, their scores are not added.
If the problem number is between 1 to 8, it first checks if the question number is same as the 0th index§. If it is, then it compares the scores of the two and stores the maximum in the ‘score’ variable. If the question number encountered is not the same as the 0th index§, then it just stores the score of the question in the ‘score’ variable.