Compare two lists Python

While programming in python, comparison has to be done very often for checking different conditions. We may need to compare two variables or two groups of variables for a single condition checking. In this article we will try different ways to compare two lists in python. While comparing, we will have to check if both the lists contain the same elements or not irrespective of the order in which the elements are present in the lists. Accordingly, we will have to print the result.

Compare two lists using sort[] method

To check whether two lists contain the same elements or not, we can use  the sort[] method to sort the elements of the lists first. Then, we can compare the two lists.

For comparison,first we will check if the length of the lists are equal or not. If the lengths are not equal, the lists will be automatically considered as different. 

If the length of the lists are the same, we will sort the two lists. Then we will compare the lists using the == operator to check whether the lists are equal or not. If the sorted lists are equal, it will establish that both the original lists contain the same elements. This can be implemented as follows.

# function to compare lists def compare[l1, l2]: # here l1 and l2 must be lists if len[l1] != len[l2]: return False l1.sort[] l2.sort[] if l1 == l2: return True else: return False list1 = [1, 2, 3, 4] list2 = [1, 4, 3, 2] list3 = [2, 3, 4, 5] print["list1 is:",list1] print["list2 is:",list2] print["list3 is:",list3] # comparing list1 and list 2 print["list1 and list2 contain same elements:",compare[list1, list2]] #comparing list2 and list3 print["list1 and list3 contain same elements:",compare[list1, list3]]

Output:

list1 is: [1, 2, 3, 4] list2 is: [1, 4, 3, 2] list3 is: [2, 3, 4, 5] list1 and list2 contain same elements: True list1 and list3 contain same elements: False

Compare using sets in Python

To compare two lists in python, we can use sets. A set in python only allows unique values in it. We can use this property of sets to find if two lists have the same elements or not.

For comparison,first we will check if the length of the lists are equal or not. If the lengths are not equal, the lists will be automatically flagged as different.

After that, we will convert the lists into sets using set[] constructor. We can compare the two sets using the == operator to check if both the sets are equal or not. If both sets are equal, it will be established that both the lists contain equal values. Following example illustrates this concept.

# function to compare lists def compare[l1, l2]: # here l1 and l2 must be lists if len[l1] != len[l2]: return False set1 = set[l1] set2 = set[l2] if set1 == set2: return True else: return False list1 = [1, 2, 3, 4] list2 = [1, 4, 3, 2] list3 = [2, 3, 4, 5] print["list1 is:", list1] print["list2 is:", list2] print["list3 is:", list3] # comparing list1 and list 2 print["list1 and list2 contain same elements:", compare[list1, list2]] # comparing list2 and list3 print["list1 and list3 contain same elements:", compare[list1, list3]]

Output:

list1 is: [1, 2, 3, 4] list2 is: [1, 4, 3, 2] list3 is: [2, 3, 4, 5] list1 and list2 contain same elements: True list1 and list3 contain same elements: False

Compare two lists using frequency counter

We can also compare two lists without comparing their lengths. For this, first we will have to create a python dictionary for each list which will keep track of the frequency of the elements in the lists. After creating the dictionaries where elements of the lists are stored as keys and their frequency are stored as values, we can compare the frequency of each element in the two dictionaries. If the frequency of each elements becomes equal, it will be confirmed that both the lists contained equal elements.

For this task, we can use the counter[] method. The counter[] method, when invoked on a list, creates a python dictionary and stores the elements as keys and their frequency as values in it. After invoking the counter[] method, we can compare the created dictionary using == operator to check whether the frequency of every element is equal or not. If the result is True, the lists contain equal elements. Otherwise not. This can be seen from the following example.

import collections # function to compare lists def compare[l1, l2]: # here l1 and l2 must be lists if len[l1] != len[l2]: return False counter1 = collections.Counter[l1] counter2=collections.Counter[l2] if counter1 == counter2: return True else: return False list1 = [1, 2, 3, 4] list2 = [1, 4, 3, 2] list3 = [2, 3, 4, 5] print["list1 is:", list1] print["list2 is:", list2] print["list3 is:", list3] # comparing list1 and list 2 print["list1 and list2 contain same elements:", compare[list1, list2]] # comparing list2 and list3 print["list1 and list3 contain same elements:", compare[list1, list3]]

Output:

list1 is: [1, 2, 3, 4] list2 is: [1, 4, 3, 2] list3 is: [2, 3, 4, 5] list1 and list2 contain same elements: True list1 and list3 contain same elements: False

Conclusion

In this article, we have seen three different ways to compare two lists in python and have checked if they contain the same elements without considering the position of the elements. To read more about lists, read this article on list comprehension.

In the compare[] function used in the examples, it may be possible that user passes two other objects instead of lists. In such cases, the program may run into error. To avoid this, we can use exception handling using python try except to avoid runtime errors by applying type checking using type[] method in try-except block to check if the objects passed as arguments are lists.

Course: Python 3 For Beginners

Over 15 hours of video content with guided instruction for beginners. Learn how to create real world applications and master the basics.

There are various ways in which the difference between two lists can be generated. In this article, we will see the two most important ways in which this can be done. One by using the set[] method, and another by not using it. 
 

Examples:  

Input : list1 = [10, 15, 20, 25, 30, 35, 40] list2 = [25, 40, 35] Output : [10, 20, 30, 15] Explanation: resultant list = list1 - list2

 Note: When you have multiple same elements then this would not work. In that case, this code will simply remove the same elements.
In that case, you can maintain a count of each element in both lists.

By the use of set[]: 
 

In this method, we convert the lists into sets explicitly and then simply reduce one from the other using the subtract operator. For more reference on set visit Sets in Python. 
 

Example: 

def Diff[li1, li2]:

    return list[set[li1] - set[li2]] + list[set[li2] - set[li1]]

li1 = [10, 15, 20, 25, 30, 35, 40]

li2 = [25, 40, 35]

print[Diff[li1, li2]]

Output : 
 

[10, 20, 30, 15]

Without using the set[]: 
 

In this method, we use the basic combination technique to copy elements from both the list with a regular check if one is present in the other or not. 
 

Example:

def Diff[li1, li2]:

    li_dif = [i for i in li1 + li2 if i not in li1 or i not in li2]

    return li_dif

li1 = [10, 15, 20, 25, 30, 35, 40]

li2 = [25, 40, 35]

li3 = Diff[li1, li2]

print[li3]

Output : 

[10, 20, 30, 15]

A while ago I wrote a guide on how to compare two dictionaries in Python 3, and how this task is not as simple as it might sound. It turns out comparing two lists in Python is just so tricky as comparing dicts.

The way we learn to compare two objects in Python is by using either the == or the is operator. In reality, these two operators cover just a small fraction of the most frequent use cases.

For example:

  • what if we want to compare a list of floating-point numbers considering a certain tolerance?
  • what if we wish to contrast two lists but ignoring the order in which the elements appear?
  • maybe we need to compare two lists and return the elements that intersect both
  • sometimes we might want to get the difference between two lists
  • what if we have two lists of strings and need to compare them by ignoring the string cases?
  • what if we're given a list of numpy arrays to compare each other, what can we do?
  • or maybe we have a list of custom objects, or a list of dictionaries.

The list goes on and on, and for all of these use cases using == doesn't help.

That's what we are going to see in this article. We’ll learn the best ways of comparing two lists in Python for several use cases where the == operator is not enough.

Ready? Let's go!

The easiest way to compare two lists for equality is to use the == operator. This comparison method works well for simple cases, but as we'll see later, it doesn't work with advanced comparisons.

An example of a simple case would be a list of int or str objects.

numbers = [1, 2, 3] target = [1, 2, 3] numbers == target True [1, 2, 3] == [1, 3, 2] False ['name', 'lastname'] == ['name', 'lastname'] True ['name', 'lastname'] == ['name', 'last name'] False

Pretty simple, right? Unfortunately, the world is complex, and so is production grade code. In the real world, things get complicated really fast. As an illustration, consider the following cases.

Suppose you have a list of floating points that is built dynamically. You can add single elements, or elements derived from a mathematical operation such as 0.1 + 0.1.

numbers = [] numbers.append[0.1 + 0.1 + 0.1] numbers.append[0.2] target = [0.3, 0.2] numbers == target False numbers [0.30000000000000004, 0.2] target [0.3, 0.2]

Clearly, floating point arithmetic has its limitations, and sometimes we want to compare two lists but ignore precision errors, or even define some tolerance. For cases like this, the == operator won’t suffice.

Things can get more complicated if the lists have custom objects or objects from other libraries, such as numpy.

In [1]: import numpy as np In [2]: numbers = [np.ones[3], np.zeros[2]] In [3]: numbers Out[3]: [array[[1., 1., 1.]], array[[0., 0.]]] In [4]: target = [np.ones[3], np.zeros[2]] In [5]: numbers == target --------------------------------------------------------------------------- ValueError Traceback [most recent call last] in ----> 1 numbers == target ValueError: The truth value of an array with more than one element is ambiguous. Use a.any[] or a.all[]

You might also like to compare the lists and return the matches. Or maybe compare the two lists and return the differences. Or perhaps you want to compare two lists ignoring the duplicates, or compare a list of dictionaries in Python.

In every single case, using == is not the answer, and that's what we are going to see next: how to perform complex comparison operations between two lists in Python.

In the previous section, we saw that floating point arithmetic can cause precision errors. If we have a list of floats and want to compare it with another list, chances are that the == operator won't help.

Let's revisit the example from the previous section and see what is the best way of comparing two lists of floats.

numbers = [] numbers.append[0.1 + 0.1 + 0.1] numbers.append[0.2] target = [0.3, 0.2] numbers == target False numbers [0.30000000000000004, 0.2] target [0.3, 0.2]

As you see, 0.1 + 0.1 + 0.1 = 0.30000000000000004, which causes the comparison to fail. Now, how can we do better? Is it even possible?

There are a few ways of doing approaching this task. One would be to create our own custom function, that iterates over the elements and compare it one by one using the math.isclose[] function.

Fortunately we don't have to reinvent the wheel. As I showed in the "how to compare two dicts" article, we can use a library called deepdiff for that. This library supports different types of objects and lists are one of them.

The example below starts off by setting up the two lists we want to compare. We then pass it to the deepdiff.DeepDiff constructor which returns the difference. That's great, the returned value is much more informative than a simple boolean.

Since we want to ignore the precision error, we can set the number of digits AFTER the decimal point to be used in the comparison.

The result is an empty dict, which means the lists are equal. If we try comparing a list with a float number that differs in more than 3 significant digits, the library will return that diff.

For reproducibility, in this article I used the latest version of deepdiff which is 5.6.0.

In [1]: from deepdiff import DeepDiff In [2]: numbers = [] In [3]: numbers.append[0.1 + 0.1 + 0.1] In [4]: numbers.append[0.2] In [5]: target = [0.3, 0.2] In [6]: DeepDiff[numbers, target] Out[6]: {'values_changed': {'root[0]': {'new_value': 0.3, 'old_value': 0.30000000000000004}}} In [7]: DeepDiff[numbers, target, significant_digits=3] Out[7]: {} In [8]: numbers Out[8]: [0.30000000000000004, 0.2] In [9]: target = [0.341, 0.2] In [10]: DeepDiff[numbers, target, significant_digits=3] Out[10]: {'values_changed': {'root[0]': {'new_value': 0.341, 'old_value': 0.30000000000000004}}}

Lists in Python are unordered by default. Sometimes we want to compare two lists but treat them as the same as long as they have the same elements—regardless of their order.

There are two ways of doing this:

  • sorting the lists and using the == operator
  • converting them to sets and using the == operator
  • using deepdiff

These first two methods assume the elements can be safely compared using the == operator. This approach doesn’t work for floating-point numbers, and other complex objects, but as we saw in the previous section, we can use deepdiff.

You can sort lists in Python in two different ways:

  • using the list.sort[] method
  • using the sorted[] function

The first method sorts a list in place, and that means your list will be modified. It's a good idea to not modify a list in place as it can introduce bugs that are hard to detect.

Using sorted is better since it returns a new list and keep the original unmodified.

Let's see how it works.

In [6]: numbers = [10, 30, 20] In [7]: target = [10, 20, 30] In [8]: numbers == target Out[8]: False In [9]: sorted[numbers] == sorted[target] Out[9]: True In [10]: sorted[numbers] Out[10]: [10, 20, 30] In [11]: sorted[target] Out[11]: [10, 20, 30]

As a consequence, by sorting the lists first we ensure that both lists will have the same order, and thus can be compared using the == operator.

Contrary to lists, sets in Python don’t care about order. For example, a set {1, 2, 3} is the same as {2, 3, 1}. As such, we can use this feature to compare the two lists ignoring the elements’ order.

To do so, we convert each list into a set, then using the == to compare them.

In [12]: numbers = [10, 30, 20] In [13]: target = [10, 20, 30] In [14]: set[numbers] == set[target] Out[14]: True In [15]: set[numbers] Out[15]: {10, 20, 30} In [16]: set[target] Out[16]: {10, 20, 30}

This library also allows us to ignore the order in sequences such as lists. By default, it will take the order in consideration, but if we set ignore_order to True, then we're all good. Let's see this in action.

In [11]: numbers = [10, 30, 20] In [12]: target = [10, 20, 30] In [13]: DeepDiff[numbers, target] Out[13]: {'values_changed': {'root[1]': {'new_value': 20, 'old_value': 30}, 'root[2]': {'new_value': 30, 'old_value': 20}}} In [14]: DeepDiff[numbers, target, ignore_order=True] Out[14]: {}

Using deepdiff has pros and cons. In the end, it is an external library you need to install, so if you can use a set to compare the lists, then stick to it. However, if you have other use cases where it can shine, then I’d go with it.

In this section, we'll see how we can compare two lists and find their intersection. In other words, we want to find the values that appear in both.

To do that, we can once more use a set and take their intersection.

In [1]: t1 = [2, 1, 0, 7, 4, 9, 3] In [2]: t2 = [7, 6, 11, 12, 9, 23, 2] In [3]: set[t1].intersection[set[t2]] Out[3]: {2, 7, 9} In [4]: set[t1] & set[t2] Out[4]: {2, 7, 9}

We can the find difference between two lists in python in two different ways:

  • using set
  • using thedeepdiff library

Just like we did to determine the intersection, we can leverage the set data structure to check difference between two lists in python.

If we want to get all the elements that are present in the first list but not in the second, we can use the set.difference[].

On the other hand, if we want to find all the elements that are in either of the lists but not both, then we can use set.symmetric_difference[].

In [8]: t1 = [2, 1, 0, 7, 4, 9, 3] In [9]: t2 = [7, 6, 11, 12, 9, 23, 2] In [10]: set[t1].difference[set[t2]] Out[10]: {0, 1, 3, 4} In [11]: set[t2].difference[set[t1]] Out[11]: {6, 11, 12, 23} In [12]: set[t1].symmetric_difference[set[t2]] Out[12]: {0, 1, 3, 4, 6, 11, 12, 23} In [13]: set[t1] - set[t2] Out[13]: {0, 1, 3, 4} In [14]: set[t1] ^ set[t2] Out[14]: {0, 1, 3, 4, 6, 11, 12, 23}

This method has a limitation: it groups what is different between the lists into one final result which is the set difference. What if we want to know which elements in that diff belong to what list?

As we've seen so far, this library is powerful and it returns a nice diff. Let's see what happens when we use deepdiff to get the difference between two lists in Python.

In [15]: t1 = [2, 1, 0, 7, 4, 9, 3] In [16]: t2 = [7, 6, 11, 12, 9, 23, 2] In [17]: DeepDiff[t1, t2] Out[17]: {'values_changed': {'root[0]': {'new_value': 7, 'old_value': 2}, 'root[1]': {'new_value': 6, 'old_value': 1}, 'root[2]': {'new_value': 11, 'old_value': 0}, 'root[3]': {'new_value': 12, 'old_value': 7}, 'root[4]': {'new_value': 9, 'old_value': 4}, 'root[5]': {'new_value': 23, 'old_value': 9}, 'root[6]': {'new_value': 2, 'old_value': 3}}} In [18]: DeepDiff[t1, t2, ignore_order=True] Out[18]: {'values_changed': {'root[4]': {'new_value': 6, 'old_value': 4}, 'root[6]': {'new_value': 11, 'old_value': 3}, 'root[1]': {'new_value': 12, 'old_value': 1}}, 'iterable_item_added': {'root[5]': 23}, 'iterable_item_removed': {'root[2]': 0}}

Accordingly, deepdiff returns what changed from one list to the other. The right approach then will depend on your use case. If you want a detailed diff, then use DeepDiff. Otherwise, just use a set.

Comparing two lists of string in Python depends largely on what type of comparison you want to make. That's because we can compare a string in a handful of ways.

In this section, we'll see 3 different ways of doing that.

The simplest one is using a == operator, like we saw in the beginning. This method is suitable if you want a strict comparison between each string.

In [1]: names = ['jack', 'josh', 'james'] In [2]: target = ['jack', 'josh', 'james'] In [3]: names == target Out[3]: True

Things start to get messy if you want to compare the list of strings but ignoring the case. Using the == for that just doesn't work.

In [4]: names = ['Jack', 'Josh', 'James'] In [2]: target = ['jack', 'josh', 'james'] In [5]: names == target Out[5]: False

The best tool for that is again deepdiff. It allows us to ignore the string by passing a boolean flag to it.

In [1]: import deepdiff In [2]: names = ['Jack', 'Josh', 'James'] In [3]: target = ['jack', 'josh', 'james'] In [4]: deepdiff.DeepDiff[names, target, ignore_string_case=True] Out[4]: {} In [5]: deepdiff.DeepDiff[names, target] Out[5]: {'values_changed': {'root[0]': {'new_value': 'jack', 'old_value': 'Jack'}, 'root[1]': {'new_value': 'josh', 'old_value': 'Josh'}, 'root[2]': {'new_value': 'james', 'old_value': 'James'}}}

We can also ignore the order in which the strings appear in the lists.

In [6]: names = ['Jack', 'James', 'Josh'] In [7]: target = ['jack', 'josh', 'james'] In [8]: deepdiff.DeepDiff[names, target, ignore_string_case=True, ignore_order=T ...: rue] Out[8]: {} In [9]: deepdiff.DeepDiff[names, target, ignore_string_case=True] Out[9]: {'values_changed': {'root[1]': {'new_value': 'josh', 'old_value': 'james'}, 'root[2]': {'new_value': 'james', 'old_value': 'josh'}}}

You can also go further and perform advanced comparisons by passing a custom operator to DeepDiff.

For example, suppose you want to compare the strings but ignoring any whitespace they may have.

Or perhaps you want to perform a fuzzy matching using an edit distance metric.

To do that, we can write the comparison logic in the operator class and pass it to DeepDiff.

In this first example, we'll ignore any whitespace by trimming the strings before comparing them.

class IgnoreWhitespaceOperator: def match[self, level] -> bool: return True def give_up_diffing[self, level, diff_instance] -> bool: if isinstance[level.t1, str] and isinstance[level.t2, str]: return level.t1.strip[] == level.t2.strip[] return False

Then we can just plug into DeepDiff by adding it to the list of custom_operators, like so custom_operators=[IgnoreWhitespaceOperator[]].

In [6]: from deepdiff import DeepDiff In [13]: names = ['Jack', 'James ', ' Josh '] In [14]: target = ['Jack', 'James', 'Josh',] In [15]: DeepDiff[names, target, custom_operators=[IgnoreWhitespaceOperator[]]] Out[15]: {} In [16]: target = ['Jack', 'James', 'Josh', 'Jelly'] In [17]: DeepDiff[names, target, custom_operators=[IgnoreWhitespaceOperator[]]] Out[17]: {'iterable_item_added': {'root[3]': 'Jelly'}} In [18]: target = ['Jack', 'Josh', 'James'] In [19]: DeepDiff[names, target, custom_operators=[IgnoreWhitespaceOperator[]]] Out[19]: {'values_changed': {'root[1]': {'new_value': 'Josh', 'old_value': 'James '}, 'root[2]': {'new_value': 'James', 'old_value': ' Josh '}}} In [20]: DeepDiff[names, target, ignore_order=True, custom_operators=[IgnoreWhitespaceOperator[]]] Out[20]: {}

Comparing two lists of dictionaries in Python is definitely intricate without the help of an external library. As we've seen so far, deepdiff is versatile enough and we can use it to compare deep complex objects such as lists of dictionaries.

Let's see what happens when we pass two lists of dictionaries.

In [1]: from deepdiff import DeepDiff In [2]: first_list = [ ...: { ...: 'number': 1, ...: 'list': ['one', 'two'] ...: }, ...: { ...: 'number': 2, ...: 'list': ['one', 'two'] ...: }, ...: ] In [3]: target_list = [ ...: { ...: 'number': 3, ...: 'list': ['one', 'two'] ...: }, ...: { ...: 'number': 2, ...: 'list': ['one', 'two'] ...: }, ...: ] In [4]: DeepDiff[first_list, target_list] Out[4]: {'values_changed': {"root[0]['number']": {'new_value': 3, 'old_value': 1}}}

It outputs the exact location where the elements differ and what the difference is!

Let's see another example where a list has a missing element.

In [2]: first_list = [ ...: { ...: 'number': 1, ...: 'list': ['one', 'two'] ...: }, ...: { ...: 'number': 2, ...: 'list': ['one', 'two'] ...: }, ...: ] In [5]: target = [ ...: { ...: 'number': 3, ...: 'list': ['one', 'two'] ...: }, ...: ] In [6]: In [6]: DeepDiff[first_list, target] Out[6]: {'values_changed': {"root[0]['number']": {'new_value': 3, 'old_value': 1}}, 'iterable_item_removed': {'root[1]': {'number': 2, 'list': ['one', 'two']}}}

It says the the second dictionary has been removed, which is the case for this example.

Comparing multidimensional lists—a.k.a list of lists—is easy for deepdiff. It works just like a list of dicts.

In the example below, we have two multidimensional lists that we want to compare. When passed to DeepDiff, it returns the exact location in which the elements differ.

For example, for the position [1][0], the new value is 8, and the old is 3. Another interesting aspect is that it works for deeply nested structures, for instance, deepdiff also highlights the difference in the [2][0][0] position.

In [1]: from deepdiff import DeepDiff In [2]: first_list = [[1, 2], [3, 4], [[5]]] In [3]: target_list = [[1, 2], [8, 4], [[7]]] In [4]: DeepDiff[first_list, target_list] Out[4]: {'values_changed': {'root[1][0]': {'new_value': 8, 'old_value': 3}, 'root[2][0][0]': {'new_value': 7, 'old_value': 5}}}

When feeding the library with two identical multidimensional lists, it returns an empty response.

In [3]: target_list = [[1, 2], [8, 4], [[7]]] In [5]: second_list = [[1, 2], [8, 4], [[7]]] In [7]: DeepDiff[second_list, target_list] Out[7]: {}

Sometimes we have a list of custom objects that we want to compare. Maybe we want to get a diff, or just check if they contain the same elements. The solution for this problem couldn't be different: use deepdiff.

The following example demonstrates the power of this library. We're going to compare two lists containing a custom objects, and we'll be able to assert if they are equal or not and what are the differences.

In the example below, we have two lists of Person objects. The only difference between the two is that in the last position Person object has a different age. deepdiff not only finds the right position - [1] - but also finds that age field is different as well.

In [9]: from deepdiff import DeepDiff In [10]: first = [Person['Jack', 34], Person['Janine', 23]] In [11]: target = [Person['Jack', 34], Person['Janine', 24]] In [12]: DeepDiff[first, target] Out[12]: {'values_changed': {'root[1].age': {'new_value': 24, 'old_value': 23}}} In [14]: second = [Person['Jack', 34], Person['Janine', 24]] In [15]: DeepDiff[second, target] Out[15]: {}

In this section, we'll see how to compare two lists of numpy arrays. This is a fairly common task for those who work with data science and/or machine learning.

We saw in the first section that using the == operator doesn't work well with lists of numpyarrays. Luckily we can use... guess what!? Yes, we can use deepdiff.

The example below shows two lists with different numpy arrays and the library can detect the exact position in which they differ. How cool is that?

In [16]: import numpy as np In [17]: from deepdiff import DeepDiff In [18]: first = [np.ones[3], np.array[[1, 2, 3]]] In [19]: target = [np.zeros[4], np.array[[1, 2, 3, 4]]] In [20]: DeepDiff[first, target] Out[20]: {'values_changed': {'root[0][0]': {'new_value': 0.0, 'old_value': 1.0}, 'root[0][1]': {'new_value': 0.0, 'old_value': 1.0}, 'root[0][2]': {'new_value': 0.0, 'old_value': 1.0}}, 'iterable_item_added': {'root[0][3]': 0.0, 'root[1][3]': 4}}

In this post, we saw many ways to compare two lists in Python. The best method depends on what kind of elements we have and how we want to compare. Hopefully, you now know how to:

  • check if two lists are equal in python
  • compare two lists without order [unordered lists]
  • compare two lists in python and return matches
  • compare two lists in python and return differences
  • compare two lists of strings
  • compare two lists of dictionaries
  • compare two list of lists
  • compare two lists of objects
  • compare two lists of numpy arrays

Other posts you may like:

See you next time!

This post was originally published at //miguendes.me

Video liên quan

Chủ Đề