Q.No. 4- Write a python function that takes two lists and returns True if they have at least one common item.

Sol.-

x=[1,2,3,4]
y=[2,5,6]
a=False
for i in x:
    for z in y:
        if i==z :
            a=True
            print(a)
if a:
    print("List have at least one common element")
else:
    print("List don't have at least one common element")
    

Explain : Step 1: Take two list x and y, and one valriable which assign False. Step 2: Use for loop i in x. i is 1 for first time then check z in y if they both equal then a value change to true and print(a) Step 3: Us if condition to print following statements.

OUTPUT:

True
List have at least on common element.