Coder: UnicodeEncodeError

Hi Everyone,

I am doing two versions of the same experiment. one is running correctly, the other one, which has the exact same code can’t run and I receive this message:

File “…”, line 137, in show_instructions_and_wait
instructions_text, is_reward = get_random_cont_instructions(instruction_list)
File “…”, line 132, in get_random_cont_instructions
print(“instruction text is %s. id is %s” % (text, id))
UnicodeEncodeError: ‘ascii’ codec can’t encode character ‘\xa3’ in position 164: ordinal not in range(128)

The code in question that does’t work is this:

def get_random_instructions(instruction_list):
result = random.choice(instruction_list)
text = result[0]
id = result[1]
print(“instruction text is %s. id is %s” % (text, id))
return text, id

def show_instructions_and_wait(window):
instruction_list = [(INSTRUCTIONS_REWARD_CONTR, True), (INSTRUCTIONS_PUNISHMENT_CONTR, False)]
instructions_text, is_reward = get_random_instructions(instruction_list)
text_stim = psychopy.visual.TextStim(
win=window,
text=instructions_text,
color=(-1, -1, -1), height=30.0)
text_stim.draw(window)
window.flip()
psychopy.event.waitKeys(keyList=[‘space’])
print(“user pressed space -> go to next step !”)
return is_reward

Can someone help me? I don’t understand because this code is working in another experiment.

Thanks!!