To check if one list contains another list of different values, you can use the in keyword in an if statement. For example:
l1 = [1, 2, 3]
l2 = [4, 5, [6]]
if [6] in l1:
print("l1 contains [6]")
else:
print("l1 does not contain [6]")
if [6] in l2:
print("l2 contains [6]")
else:
print("l2 does not contain [6]")
This code will check if the list [6] is contained in the lists l1 and l2, and print a message indicating whether it is or not. The output will be:
l1 does not contain [6]
l2 contains [6]
This approach works because the in keyword checks if an element is contained in a list, regardless of the values of the elements. In this case, the element being searched for is the list [6], and the in keyword will return True if this list is contained in the list being searched, and False otherwise.
Another option is to use the any function, which returns True if any element in a list satisfies a given condition, and False otherwise. For example:
l1 = [1, 2, 3]
l2 = [4, 5, [6]]
if any(isinstance(x, list) for x in l1):
print("l1 contains a list")
else:
print("l1 does not contain a list")
if any(isinstance(x, list) for x in l2):
print("l2 contains a list")
else:
print("l2 does not contain a list")
This code will check if any element in the lists `