Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

#Check if list1 contains all elements of list2 using all()

# List of string 
list1 = ['Hi' ,  'hello', 'at', 'this', 'there', 'from']
# List of string
list2 = ['there' , 'hello', 'Hi']
'''    
    check if list1 contains all elements in list2
'''
result =  all(elem in list1  for elem in list2)
if result:
    print("Yes, list1 contains all elements in list2")    
else :
    print("No, list1 does not contains all elements in list2"
Comment

PREVIOUS NEXT
Code Example
Python :: python paho mqtt on_connect 
Python :: python slice last 2 items of list 
Python :: append two dfs 
Python :: pil saves blue images 
Python :: seaborn bar plot sort for weekday 
Python :: pytorch tensor argmax 
Python :: convert numpy array to tfrecord and back 
Python :: flask tutorial 
Python :: install python 3 
Python :: python print main arguments 
Python :: python generalised eigenvalue problem 
Python :: munshi premchand idgah 
Python :: opposite case in python 
Python :: dependency inversion 
Python :: how to encrypt and decrypt strings python 
Python :: find daily aggregation in pandas 
Python :: how to pick the latest data entered django 
Python :: raspberry pi python 
Python :: powershell bulk rename and add extra string to filename 
Python :: dataframe rolling first eleemnt 
Python :: copy module in python 
Python :: how to use with statement in python 2.5 and earlier 
Python :: how to use with statementin python 2.4 
Python :: pandas interpolate string 
Python :: how to adda vaslues to data frame 
Python :: how to remove whitespace from string in python 
Python :: number string array 
Python :: python list sum 
Python :: Does Flask support regular expressions in its URL routing 
Python :: how to divide string in python 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =