0

I am writing a code. I have two separate lists of urls. I want to compare the urls from list 1 with list 2 and find which urls from list 1 are already there in list 2. I am coding in python.

1 Answers1

0

I know I commented but it seems like you are looking for a Set intersection. You want the URLs that are common between both lists.

list1 = ["some_url", "another_url", "some_other_url"]
list2 = ["another_url", "some_different_url"]
result = set(list1).intersection(set(list2)) # { "another_url" }
Jack Ryan
  • 1,287
  • 12
  • 26