'Why does my input convert 'A' and 'B' to 'B' and 'B'

I am working on the following problem: https://dmoj.ca/problem/ccc11s2

For some reason, when I input A, B, A, B, it converts the A's to B's in the code below. Can anyone help me understand what is happening and where my code is going wrong? It seems like the only sum I get is 1 and I don't know where i'm messing up.

#The input will contain the number () followed by lines. The lines are composed of lines of student responses (with one of A, B, C, D or E on each line), followed by lines of correct answers (with one of A, B, C, D or E on each line), in the same order as the student answered the questions (that is, if line is the student response, then line will contain the correct answer to that question)

n = int(input())

sum = 0

for s in range(n):

student = input()

for t in range(n):

teacher = input()

for i in range(len(student)):

if student[i] == 'A' and teacher[i] == 'A':
    sum = sum + 1
elif student[i] == 'B' and teacher[i] == 'B':
    sum = sum + 1
elif student[i] == 'C' and teacher[i] == 'C':
    sum = sum + 1
elif student[i] == 'D' and teacher[i] == 'D':
    sum = sum + 1
elif student[i] == 'E' and teacher[i] == 'E':
    sum = sum + 1
else:
    sum = sum

print(sum)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source