I am trying to create an input-based program to ask students to input their responses to each question, then compare them to the answer key[dict]. If value is matched to input, add a point.
In my current code I have already found an issue where if I input "A,B,C" as the first responses and "A" for the rest, my result says 8,9,10 are correct although they are not.
What is my error in my for loop? I would also like some recommendations on how to improve this or to change my current logic altogether.
QUANTITY_TEST_QUESTIONS = 10
ANSWERKEY = {
1:"a", 2:"b", 3:"c", 4:"d", 5:"e",
6:"e", 7:"d", 8:"c", 9:"b", 10:"a"
}
def student_response():
responseList = []
for i in range(0, QUANTITY_TEST_QUESTIONS):
student_response = input("Enter your response: ")
# student_response = student_response.title()
responseList.append(student_response)
print(responseList)
return responseList
def compare_response_to_answerKey(ANSWERKEY:Dict, responseList):
points = 0
for k, v in ANSWERKEY.items():
if v in responseList:
points += 1
print(f"Correct Answers:{k}")