Hi everyone. I’ve created an experiment in psychopy using the builder view and I’ve added some code components inside it. The code component contains some functions and it actually works well but in order to put it online I need to put functions into a variable.
I’m a kind of beginner to python and programming and I tried to do what I want but after putting function into a variable it doesn’t do its task properly.
This is a piece of my code:
def num1_to_sec(n): return float(0.250 * n) def num2_to_sec(n): return float(0.270 * n) rann=randint(0,1) def stopSDVIS(rann): if rann==0: return num1_to_sec(listSD[a][b][c]) elif rann==1: return num2_to_sec(listSD[a][b][c])
The function I need to put into a variable is stopSDVIS(rann). I tried these three ways:
They don’t end up in error but all these three ways produce incorrect outcomes.
So in a nutshell I want to know how to put my python function into a variable.
Thanks in advance for your help.