I do want the indexes, at the end I'm trying to print out a list of the incorrectly answered questions so question 1 == index 0.
def main(): # Constant of correct test answers. CORRECT_ANSWERS = ["A", "C", "A", "A", "D", "B", "C", "A", "C", "B", "A", "D", "C", "A", "D", "C", "B", "B", "D", "A"] # filling a list with every line, stripped of the \n, from the opened file student_answers = [line.strip('\n') for line in open('test.txt', 'r')] student_correct = 0 incorrect_num = [(index + 1) if CORRECT_ANSWERS[index] != student_answers[index] else (student_correct + 1) for index in range(len(CORRECT_ANSWERS))] print(incorrect_num) print(student_correct) main()now my output is
Output:[1, 1, 1, 1, 5, 1, 7, 1, 1, 10, 1, 1, 1, 1, 15, 1, 1, 1, 1, 20]
0
The list of incorrectly answered questions should be [1,5,7,10,15,20] and 14 should be the student_correct value.