I have a lists of tuples (>150k elements) containing an ID with the length of that ID. However, this list should only show IDs that appear in the second list (>80k).
list_of_tuples = [('1', 31.46), ('10', 97.99), ('50', 71.19), ('100', 17.03), ...]
normal_list = ['1', '50', '100', ...]
The desired output is:
list_of_tuples = [('1', 31.46), ('50', 71.19), ('100', 17.03), ...]
Here's the code that I threw together for testing the concept, but as I am new to Python, it doesn't work. I also haven't found a solution online for this kind of issue.
for whole_elem in list_of_tuples:
for first_elem in whole_elem:
for link in normal_list:
if first_elem <> link
list_of_tuples.pop(whole_elem)
I would appreciate your support a lot. Thank you very much!