I am trying to search for the first occurrence of a dictionary in a list. The logic I created works well for the small data but I have a list of a million rows and the other list elements to search has 1000 elements.
data = [{'team': 'a', 'id':11}, {'team': 'b', 'id':111}, {'team': 'c', 'id':1111}]
list_to_see = ['a','c']
check = None
for index in range(len(data)):
if data[index]['team'] in list_to_see[index]:
check = data[index]['id']
break
print(check)
#Output: 11
So, I got the first element Id which is exactly what I want in the result. Is there any optimized way to get the same output that can handle large data? Thanks