Error code:
if lstAns[i]==correct[i]:
TypeError: 'function' object is not subscriptable
Full code:
CorrectAnswer= ['B','D','A','A','B','A','B','A','C','D','B','C','D','A','D','C','C','B','D','A']
def BDAABABACDBCDADCCBDA():
SA=open("StudentAnswers.txt","w")
SA.write("Answers are\n".format(BDAABABACDBCDADCCBDA))
SA.close()
def lstAns():
lstAns=list(SA.read())
correct=0;
incorrect=0;
for i in range(20):
if lstAns[i]==correct[i]:
correct+=1
elif lstAns[i] != correct[i]:
incorrect+=1
print("Correct answers: ",correct)
print("Incorrect answers: ",incorrect)
print("Student answer: ")
for i in range(20):
print(i+1,userlist[i])
What I have tried:
I don't know what to try with this error code every time I look up solutions to the error code I cant figure out how to apply them to the specific code above