I have a list with urls: file_url_list
, which prints to this:
www.latimes.com, www.facebook.com, affinitweet.com, ...
And another list of the Top 1M urls: top_url_list
, which prints to this:
[1, google.com], [2, www.google.com], [3, microsoft.com], ...
I want to find how many URLs in file_url_list
are in top_url_list
. I have written the following code which works, but I know that it's not the fastest way to do it, nor the most pythonic one.
# Find the common occurrences
found = []
for file_item in file_url_list:
for top_item in top_url_list:
if file_item == top_item[1]:
# When you find an occurrence, put it in a list
found.append(top_item)
How can I write this in a more efficient and pythonic way?