Hello guys. How are you all? I hope you all fine. In this tutorial we will learn about How to check List Equality in Python. so without wasting time lets learn about of this.
How to check List Equality in Python
check List Equality in Python
to check List Equality in Python just Use == operator. By using == you can check if both the list are equal or not. Lets learn about of this by given below example:
l1 = [11,12,13,14,15] l2 = [12,1,8,15,14,8] l3 = [11,12,13,14,15] print(l1 == l2) print(l1 == l3)
Output :False True
How to check List Equality in Python
to check List Equality in Python just Use == and numpy.all().By using == and numpy.all() you can check if both the list are equal or not. Lets learn about of this by given below example:
import numpy as np l1 = [11,12,13,14,15] l2 = [12,1,8,15,14,8] l3 = [11,12,13,14,15] print((np.array(l1) == np.array(l2))) print((np.array(l1) == np.array(l3)))
Output :False [ True True True True True]
python list equality
To check List Equality in Python just Use == and numpy.all().By using == and numpy.all() you can check if both the list are equal or not. Lets learn about of this by given below example:
import numpy as np l1 = [11,12,13,14,15] l2 = [12,1,8,15,14,8] l3 = [11,12,13,14,15] print((np.array(l1) == np.array(l2))) print((np.array(l1) == np.array(l3)))
Output :False [ True True True True True]
Method 1: Use == operator
By using == you can check if both the list are equal or not. Lets learn about of this by given below example:
l1 = [11,12,13,14,15]
l2 = [12,1,8,15,14,8]
l3 = [11,12,13,14,15]
print(l1 == l2)
print(l1 == l3)
Output :
False
True
Method 2: Use == and numpy.all()
By using == and numpy.all() you can check if both the list are equal or not. Lets learn about of this by given below example:
import numpy as np
l1 = [11,12,13,14,15]
l2 = [12,1,8,15,14,8]
l3 = [11,12,13,14,15]
print((np.array(l1) == np.array(l2)))
print((np.array(l1) == np.array(l3)))
Output :
False
[ True True True True True]
Conclusion
It’s all About this Tutorial. Hope all methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you?
Also, Read