check if two lists have same elements irrespective of order using if else statements in python
Answers
Answered by
0
Answer:
Here is the answer, please take care of the indentation in your system. The program is in Python3. Here I have taken two lists for example. In the for loop each value present in L1 is checked in L2. If a value is not present then the lists are unqual.
Explanation:
L1=[2,4,5,6]
L2=[2,5,4,6]
flag=0
for i in L1:
if i not in L2:
flag=1
break
if flag==1:
print("lists are unequal")
else:
print("lists are equal")
Similar questions