#compare
all() and any()
all() method demonstrates if List1 has List2 elements
all() and any()
all() method demonstrates if List1 has List2 elements
# List1
List1 = ['python' , 'javascript', 'csharp', 'go', 'c', 'c++']
# List2
List2 = ['csharp1' , 'go', 'python']
check = all(item in List1 for item in List2)
any() checks if the list contains any elements of another one:# List1
List1 = ['python' , 'javascript', 'csharp', 'go', 'c', 'c++']
# List2
List2 = ['swift' , 'php', 'python']
check = any(item in List1 for item in List2)