error: EOF when Reading a line

Asked

Viewed 88 times

-1

I need to round the notes to the next multiple of 5, if it is greater than 38 and the difference is less than 3. However, when I am going to submit the code to me d[and the error:

EOF when Reading a line

What I’m doing wrong?

def gradingStudents(grades):
    n = int(input('alunos: '))

    for i in range(n):
        if grades[i] < 38:
            grades[i] += 0
        elif grades[i] % 5 == 3:
            grades[i] += 2
        elif grades[i] % 5 == 4:
            grades[i] += 1
    return grades

print(gradingStudents([73, 67, 38, 33]))
  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).

1 answer

1

It makes no sense to ask the number of students, you already know with the list being sent, just ask the size of the list to use with the function len(). Even asking the user to type manually, if typing the correct size is not to give error. I have not checked whether the rest of the algorithm is right because the question is not about this and because the statement, in the posted form, is confused.

def gradingStudents(grades):
    n = len(grades)
    for i in range(n):
        if grades[i] < 38:
            grades[i] += 0
        elif grades[i] % 5 == 3:
            grades[i] += 2
        elif grades[i] % 5 == 4:
            grades[i] += 1
    return grades

print(gradingStudents([73, 67, 38, 33]))

Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.