checking correct answer
Hi,
In my experiment I have loop of movies and for each movie 4 questions. I want to give the user a feedback for each movie - how many answers he got correct.
The questions and correct answers are given in Excel file (the variable for the correct answer is theCorrectAnswer) and when in the feedback I printed "theCorrectAnswer" and the answer that the user pressed in in "response_answer_1".
I added inline script for each question so that I can check whether "theCorrectAnswer" was equal to "response_answer_1". This is my script:
if (theCorrectAnswer == response_answer_1)
total_correct_answers = total_correct_answers + 1
[I set total_correct_answers to 0 before]
and I got the following error:
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\inline_script.py", line 73, in prepare
self.var.get(u'_run', _eval=False))
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\python_workspace.py", line 147, in _compile
return compile(script, u'', u'exec')
File "", line 2
if (theCorrectAnswer == response_answer_1)
^
SyntaxError: invalid syntax
What is the correct way to write it?
Comments
Hi, in Python, if-statements need a double point (": "), so in your case,
Cheers
Josh
Thanks a lot!!