I am not very used to pyhton and want to write a function that takes an array x as an input and gives an array back (select) consisting only of those entries of the input array that fulfil a certain property, e.g. being in a certain range. The function that should do this is the following:
def select(x):
count = 0
select = [] #0
for i in range(0,len(x[0])):
if ( (int(x[4][i])+0.5) > x[4][i] > (int(x[4][i])-0.5) ):
select[0][count]=x[0][i] #1
select[1][count]=x[1][i] #2
select[2][count]=x[4][i] #3
count = count + 1
return select
However, if I call that function I get the following error message:
IndexError: list index out of range
the line causing it is "#1" (and the 2 following lines are making trouble too I think). I guess I have to define the array size in some way. How can I do that in python in that case? As I see select=[] is not enough.
Kind regards
xand outputselectto be for some case?