Your code is returned as soon as the first element exists in both lists. To check all the elements, you can try this, for example:
def detect(list_a, list_b):
return set(list_a).issubset(list_b)
Another possibility without creating set:
def detect(list_a, list_b):
return all(x in list_b for x in list_a)
And in case you were curious what exactly is wrong in your code, this is a fix in its current form (but this is not very pythonic):
def detect(list_a, list_b):
for item in list_a:
if item not in list_b:
return False
return True
, , . detect . , isSubset ..