0:23 Identity Matters Use 'is' operator to check if the object references point to the same object in stored in memory. 1:40 Order and Duplicates Matter Use '==' operator to check the index of each list refers to the same object. *Assumes objects in the list can be compared using equality. 3:48 Order Ignored, Duplicates Matter from collections import Counter. Counter creates a counter object that is a dictionary. It contains unique objects as the key and the number of times it occurs is that value. From here, you can compare the two Counter objects using '==' operator. *Assumes objects in the list are hashable and supports equality 6:46 Order Ignored, Duplicates Ignored Convert each list to a set. Sets only contain unique objects. Use '==' operator to compare the sets to check if the lists contain the same objects, ignoring the order and quantity of each object. *Assumes objects in the list are hashable and supports equality.
0:23 Identity Matters
Use 'is' operator to check if the object references point to the same object in stored in memory.
1:40 Order and Duplicates Matter
Use '==' operator to check the index of each list refers to the same object.
*Assumes objects in the list can be compared using equality.
3:48 Order Ignored, Duplicates Matter
from collections import Counter. Counter creates a counter object that is a dictionary. It contains unique objects as the key and the number of times it occurs is that value. From here, you can compare the two Counter objects using '==' operator.
*Assumes objects in the list are hashable and supports equality
6:46 Order Ignored, Duplicates Ignored
Convert each list to a set. Sets only contain unique objects. Use '==' operator to compare the sets to check if the lists contain the same objects, ignoring the order and quantity of each object.
*Assumes objects in the list are hashable and supports equality.
Thanks for this video.
You bet!
How to compare sublists of two list
A=[[1,2,3],[1,3,5]]
B=[[1,2,3],[1,6,2]]