Python determines whether two lists are instances of parent-child set relationship

不言
Release: 2018-05-05 10:26:34
Original
2657 people have browsed it

This article mainly introduces the example of Python's judgment of whether two lists are parent-child set relationships. It has a certain reference value. Now I share it with you. Friends in need can refer to

list1 and list2 Two lists, want to get whether list1 contains list2 (whether it is a subset)

a = [1,2] 
b = [1,2,3] 
c = [0, 1] 
 
set(b) > set(a) 
set(b) > set(c)
Copy after login

Return

True 
False
Copy after login

Related recommendations:

Whether a python list contains all elements of another list

Python implementation example of finding all subsets of a set

Python method to determine whether a set is a subset of another set

The above is the detailed content of Python determines whether two lists are instances of parent-child set relationship. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!