522 B
522 B
title, tags
| title | tags |
|---|---|
| is_contained_in | list,intermediate |
Returns True if the elements of the first list are contained in the second one regardless of order, False otherwise.
- Use
count()to check if any value inahas more occurences than it has inb, returningFalseif any such value is found,Trueotherwise.
def is_contained_in(a, b):
for v in set(a):
if a.count(v) > b.count(v):
return False
return True
is_contained_in([1, 4], [2, 4, 1]) # True