Reputation: 33293
Let's say I have an arbitrary number of lists (so list of lists). All lists are of same size, An example of this might be
say, k lists of length 4 (k=2)
[
[A, B, C, D] # length 4
[A, F, G, D] # length 4
]
Now given a query_list
[A, B, C, E]
This should return [A, B, C, D]
which is the longest chain as in [A,F,G,D]
, the second character "F" and "B" in query_list mismatches..
Upvotes: 0
Views: 36
Reputation: 523
x=[ ["a","b","c"],["a","b","z"],["a","z","c"] ]
z=["a","b","c"]
arr = []
for i in x:
cnt = sum(z == y for z, y in zip(i, z))
arr.append(cnt)
index = arr.index(max(arr))
print(x[index],"matched the most")
Upvotes: 1