Jan-21-2019, 10:59 PM
Okay, this is the finished product.
def main(): CORRECT_ANSWERS = ["A" , "C" , "A" , "A" , "D" , "B" , "C" , "A" , "C" , "B" , "A" , "D" , "C" , "A" , "D" , "C" , "B" , "B" , "D" , "A"] student_answers = [] student_file = open("test.txt" , "r") for line in student_file: student_answers.append(line.rstrip('\n')) student_file.close() incorrect_num = [] correct_answers = 0 for index in range(len(CORRECT_ANSWERS)): if CORRECT_ANSWERS[index] == student_answers[index]: correct_answers += 1 else: incorrect_num.append(index + 1) if correct_answers > 14: print("The student passed.") else: print("The student failed.") print("The student got %d answer(s) correct and %d answer(s) incorrect." % (correct_answers, (20 - correct_answers))) print("This is a list of the question number(s) answered incorrectly." , incorrect_num) main()I still have to comment the whole thing. Thank you again for the help.