Answers for "python if all one list in another"

3

python check list contains another list

>>> items = set([-1, 0, 1, 2])
>>> set([1, 2]).issubset(items)
True
>>> set([1, 3]).issubset(items)
False
Posted by: Guest on April-16-2021
0

A Python list exists in another list

# Program to check the list contains elements of another list

# List1
List1 = ['python' ,  'javascript', 'csharp', 'go', 'c', 'c++']
 
# List2
List2 = ['csharp1' , 'go', 'python']

check =  all(item in List1 for item in List2)
 
if check is True:
    print("The list {} contains all elements of the list {}".format(List1, List2))    
else :
    print("No, List1 doesn't have all elements of the List2.")
Posted by: Guest on April-25-2022

Code answers related to "python if all one list in another"

Python Answers by Framework

Browse Popular Code Answers by Language