Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

correct respon not match

Hi All,
I have little problem with my coding to make correct respon from a list which contain same object:
my_stim = ['2','3','3']

experiment design goes here

pre_stim = my_stim[trial]
t_first = expyriment.stimuli.TextLine(text=pre_stim, text_bold = True, text_size=60)
t_trial = expyriment.design.Trial()
t_trial.add_stimulus(t_first)
if my_stim[trial] == '3' :
correct = 122
elif my_stim[trial] == '3' :
correct = 107
else:
correct = 122

It gave same answer in object '3' (122 not 107 in second row), then I try:

if my_stim[trial] == '3' and pre_stim == my_stim[0]:
correct = 122
elif my_stim[trial] == '3' and pre_stim == my_stim[1]:
correct = 107
else:
correct = 122
It also gave the exact same number in object '3'. Instead using list, do I have to use dict for delivering my stimuli?
Any suggest would be great!!
Thanks in advance

Comments

  • Hi,

    it is not clear to me what exactly doesn't work. In your first example you will never reach the elif, because the expression to evaluate is the same for the if before.

    In the second example they are different, though.

    What do you mean with "it also gave the exact same number in object '3'"?

  • Thanks for the respon!
    Sorry, ignore the second example, thats just silly. What I am trying to reach is like first example but evaluate the elif statement. Just like this:

    block_one = expyriment.design.Block(name="1")
    trial_one = expyriment.design.Trial() #0
    stim = expyriment.stimuli.TextLine(text='3', text_colour=expyriment.misc.constants.C_GREEN, text_bold = True, text_size=60)
    trial_one.add_stimulus(stim)
    correct = 109
    label_id = "M"
    trial_one.set_factor("correct", correct)
    trial_one.set_factor("label_id", label_id)
    trial_two = expyriment.design.Trial() #1
    stim = expyriment.stimuli.TextLine(text='2', text_colour=expyriment.misc.constants.C_GREEN, text_bold = True, text_size=60)
    trial_two.add_stimulus(stim)
    correct = 109
    label_id = "M"
    trial_two.set_factor("correct", correct)
    trial_two.set_factor("label_id", label_id)
    trial_three = expyriment.design.Trial() #2
    stim = expyriment.stimuli.TextLine(text='3', text_colour=expyriment.misc.constants.C_GREEN, text_bold = True, text_size=60)
    trial_three.add_stimulus(stim)
    correct = 120
    label_id = "X"
    trial_three.set_factor("label_id", label_id)
    trial_three.set_factor("correct", correct)

    Thanks for the answer, the time and the opensource Expyriment!!

Sign In or Register to comment.