I have a quick question, this line of code
row[time] == numbers[num_time]:
is giving me the error:
int has no attribute __getitem__
after some research, i found out that this errors occurs when you try to call a list number on an int. In this case, I am sending in a list of 3 numbers, and wanting to recurse( we arent allowed to use loops yet :( ) on the second list of numbers, seeing if any of the elements of the second list are within the first list. If they are, something will be done, but if they arent, the function should move on to the next in the row list, do the same thing, until row is empty.
def row_find(row,numbers,time,num_time):
if numbers==[]:
return row_find(row[time+1],numbers,time+1,num_time=0)
if row== []:
return row
else:
if row[time]== numbers[num_time]:
num_time=0
return row,row_find(row[time+1],numbers,time+1,num_time)
else:
return row,row_find(row[time],numbers[num_time+1],time,num_time)
lst=[5,2,9]
num_lst=[5, 10, 23, 31, 44]
row_find(lst,num_lst,0,0)