I am new to the python. I have two lists:
l1 = [1,1,1]
l2 = [1,1,1]
Now, I have to check whether these two are equal or not. I have a solution which I am currently using:
def comp(l1,l2):
#condition we are checking [1,1,1] and [1,1,1]
try:
a= set(l1) #converting a list into set , as set will return the length on basis of unique elements.
b= set(l2)
return ((a == b) and (len(a) == 1) and (len(b) == 1))
except TypeError:
return False
Now, with this I am able to solve the task. But I am trying to do it elementwise.
l1 = [1,1,12]
l2 = [1,1,1]
Then I can treat the 12 as a 1 so I need to know which number is not matching. Can any one help me with this ?