I need to see if 2 items from a list appears in another list, and if they do, compare the items by their position in the other list. Example in pseudo code:
j=0
for x in mylist #loop through the list
i=0
for y in mylist #loop through the list again to compare items
if index of mylist[j] > index of mylist[i] in list1 and list2:
score[i][j] = 1 #writes the score to a 2d array(numpy) called score
i=i+1
else:
score[i][j]=0
i=i+1
j=j+1
Sample Narrative Description:
Names = [John, James, Barry, Greg, Jenny]
Results1 = [James, Barry, Jenny, Greg, John]
Results2 = [Barry, Jenny, Greg, James, John]
loop through Names for i
loop through Names for j
if (index value for john) > (index value for james) in results1 and
(index value for john) > (index value for james) results2:
score[i][j] = 1
Can someone please point me in the right direction? I've been looking at numerous list, array and .index tutorials but nothing seems to answer my question
names[0][1]=[john, james]name listthe same asNames? Which list isindex valuereferring to?