If I have a series of lists in a dictionary (for example):
{'Name': ['Thomas', 'Steven', 'Pauly D'], 'Age': [30, 50, 29]}
and I want to find the strings position so I can then get the same position from the other list.
So e.g.
if x = 'Thomas' #is in position 2:
y = dictionary['Age'][2]
However,
indexperforms a linear search, which could be slow for a large list. In other cases similar to this, I’ve used a pattern like this:You could do the same thing with a dict if you needed the records to be different length. Either way, storing it like this will help accessing records be faster.