575 B
575 B
title, tags, cover, firstSeen, lastUpdated
| title | tags | cover | firstSeen | lastUpdated |
|---|---|---|---|---|
| List is contained in other list | list | tropical-bike | 2020-03-16T19:48:15+02:00 | 2021-01-07T23:30:28+02:00 |
Checks if the elements of the first list are contained in the second one regardless of order.
- Use
count()to check if any value inahas more occurrences than it has inb. - Return
Falseif 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