I have some dozens of tuples each containing 2 strings and 1 integer. Ex:(str, str, int)
.
All these tuples are in a list (example below).
Each tuple is unique and each tuple's strings and integer are also unique.
Ex.:
[('a','aA', 53),
('b','bb', 21),
('c','cc', 234),
('d','de', 76),
..]
What I want is, to use this data structure like a dictionary and retrieve the entire tuple for any of one of the 3 values I pass.
Ex.:
For value
'a'
-> get the whole tuple of:('a', 'aA', 53)
For value
'cc'
-> get the whole tuple of:('c', 'cc', 234)
For value
'76'
- > get the whole tuple of:('d', 'de', 76)
So far I have done: Creating a simple function to iterate through the list of tuples, go through each tuple and its all 3 values to find a match and if there's a match return the tuple, if not return False.
This sounds slow and seems like the very wrong way to do this task.
- What would be the right way to achieve this?
- Should I create 3 dictionaries and link them to each other?