Skip to content Skip to sidebar Skip to footer

Getting Intersection Of Two Lists In Python

I have two lists of genes that i'm analyzing. Essentially I want to sort the elements of these lists much in the same way as a Venn diagram, i.e. elements that only occur in list 1

Solution 1:

There is a bug in the construction of the lists.

In the section:

for i in range(0,len(list1)):
    if list1[i] not in list2:
        list1_only.append(list2[i])

the last line should be:

        list1_only.append(list1[i])

Solution 2:

You might also want to checkout this handy website:

http://jura.wi.mit.edu/bioc/tools/compare.php

Post a Comment for "Getting Intersection Of Two Lists In Python"