OS (e.g. Win10): OSX Sierra 10.12.5
PsychoPy version (e.g. 1.84.x): 1.85.2
Standard Standalone? (y/n) If not then what?:y
What are you trying to achieve?:
I am trying to code a simple reward task in which participants make a binary choice (e.g., guess high or low) about the value of a stimulus, and experience monetary gain or loss as a positive or negative outcome if they were ‘correct’ or 'incorrect. In reality there is no correct answer; reinforcement is fixed so all participants will receive a positive outcome on 50% of trials and a negative outcome on 50% of trials. On a given trial, if a participant makes a choice and it is scheduled to be a positive outcome, after making their guess, they will see a random number corresponding to their choice––e.g., guessing ‘high’ will result in the presentation of a ‘high’ number (e.g., random number between 6 and 9). If it is scheduled to be a negative outcome, if they guess high, they will see a random number corresponding to the opposite of their choice (e.g., random number between 1 and 4).
What did you try to make it work?:
I have set up the experiment file via the builder such that there are 2 main routines, a positive outcome routine and a negative outcome routine, each with a response object that can accept 2 possible responses (e.g., ‘1’, ‘2’) but not designating either of them as correct. Instead, I have inserted a code object into each routine. In the ‘begin experiment’ field, I have input the following:
outcome = 
and in the ‘begin routine’ field, I have the following code:
if response.keys == 1:
outcome = random.randint(1,4)
elif response.keys == 2:
outcome = random.randint(5,9)
elif not response.keys:
outcome = "No Response"
And in the text object that is supposed to display the outcome to them, I have insert a variable $outcome in the text field.
What specifically went wrong when you tried that?:
Upon running this, after making a response on the first trial, the experiment displays  for the outcome instead of an actual number based on my response, and on subsequent trials, regardless of whether I make a response, the outcome displayed on the screen is ‘No Response’.
Any suggestions as to how I should effectively code what I am trying to do would be much appreciated.
Thanks in advance,