Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11522 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2011-08-16 09:44 +0200 |
| Last post | 2011-08-16 09:44 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: testing if a list contains a sublist Peter Otten <__peter__@web.de> - 2011-08-16 09:44 +0200
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2011-08-16 09:44 +0200 |
| Subject | Re: testing if a list contains a sublist |
| Message-ID | <mailman.42.1313480614.27778.python-list@python.org> |
Johannes wrote: > what is the best way to check if a given list (lets call it l1) is > totally contained in a second list (l2)? > > for example: > l1 = [1,2], l2 = [1,2,3,4,5] -> l1 is contained in l2 > l1 = [1,2,2,], l2 = [1,2,3,4,5] -> l1 is not contained in l2 > l1 = [1,2,3], l2 = [1,3,5,7] -> l1 is not contained in l2 > > my problem is the second example, which makes it impossible to work with > sets insteads of lists. But something like set.issubset for lists would > be nice. Would [1, 2, 1] be contained in [1, 1, 2]? You have received an answer that assumes yes and another that assume no.
Back to top | Article view | comp.lang.python
csiph-web