I'm trying to check if a small list contains all the numbers that exist in another bigger list Case 1 :- list1 : [97,97,196] list 2 : [97,97,101,103,196]
- This should return True because all elements in list1 are already in list2
Case 2 :- list1 :[97,97,196] list 2 : [97,101,103,196]
- This should return False because list1 has two 97's while list2 only contains one 97
list1 = [97,97,196]
list2 = [97,97,99,101,103,196]
def isConsist(list1,list2):
check = False
# Iterate in the 1st list
for m in list1:
# Iterate in the 2nd list
for n in list2:
# if there is a match
if m == n:
check = True
list2.remove(n) // remove the found element
else:
check = False
return False
return check
check = isConsist(list1,list2)
print(check)
This is my code but it is not working correctly
My code got my false because when it comes to check the 196 in the first list it comapares it to 99 in the second list and then it returns False