What is the value stored in globalAnswers[2][1]? The return value of event.getKeys() is a list of keys pressed. You might want to just access the first or last key that was pressed, not the whole return value.
For debugging, you could insert a logging.debug(f'event.getKeys(): {event.getKeys()}') before your if-else block. That should show you the value of event.getKeys().
Dear @wakecarter
Thanks for your reply. This is the code:
questionMark.draw()
win.flip()
event.waitKeys()
core.wait(4)
keys = event.getKeys()
print(keys)
# if image is HH:
if i % 2 == 0 and rand == 0:
rand = 1
if [event.waitKeys[i] for i in (0)] == (globalAnswers[0][1]):
correct.draw()
win.flip()
core.wait(2)
else:
wrong.draw()
win.flip()
core.wait(2)
# if image is SS:
elif i % 2 == 0 and rand == 1:
rand = 0
if event.getKeys() == (globalAnswers[3][1]):
correct.draw()
win.flip()
core.wait(2)
else:
wrong.draw()
win.flip()
core.wait(2)
# if image is HS
if i % 2 != 0 and rand == 0:
if keys[0] == (globalAnswers[2][1]):
correct.draw()
win.flip()
core.wait(2)
else:
wrong.draw()
win.flip()
core.wait(2)
# if image is SH
elif i % 2 != 0 and rand == 1:
if event.getKeys() == (globalAnswers[1][1]):
correct.draw()
win.flip()
core.wait(2)
else:
wrong.draw()
win.flip()
core.wait(2)