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.
Asked
Active
Viewed 86 times
0
-
1Set intersection? `result = set(list1).intersection(set(list2))` or something similar perhaps? – Jack Ryan Feb 01 '20 at 04:22
-
see RFC 3986 section 6.1 – Harf Dec 12 '21 at 00:27
1 Answers
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