def main():
infile = open ('correctAnswers.txt','r')
correct = infile.readlines()
infile.close
infile1 = open ('studentAnswers.txt','r')
student = infile.readlines()
infile1.close
index=0
correctanswer=0
wronganswer=[]
while index<len(correct):
correct[index]=correct[index].rstrip('\n')
student[index]=student[index].rstrip('\n')
if correct[index]==student[index]:
correctanswer=correctanswer+1
print(index)
index=index+1
else:
wronganswer.append(index)
print(index)
index=index+1
if correctanswer>0:
print("Congratulations you passed the test.")
else:
print("I'm sorry but you did not pass the test")
print(" ")
print(" ")
print("# Correct Student ")
print("-----------------------")
for item in incorrectindex:
print(item+1," ",correctanswers[item]," ",studentanswers[item])
main()
So this is the entire program that I am executing. It reads two files that I have locally that check is a student has enough of the correct answers to pass the test. The program executes well, it produces Congratulations you passed the test.
# Correct Student
-----------------------
3 A B
7 C A
11 A C
13 C D
17 B D
The problem is that is looks very sloppy, notice how the change of numbers from single digits to double digits shifts the letters across by one space. Is there a specific way you do this because I know I will come across this issue in the future