17. Problem to print true if common elements between lists.  

We will take two lists as input & iterate all the values one by one with the python loop with the help of the below-given steps. Print True if there are any common elements between lists.

Common elements between lists:

Steps to solve the program
  1. Take two lists as input.
  2. Use a for loop to iterate over elements in the first list.
  3. Using an If statement check whether an element exists in both lists or not.
  4. If yes print True.
				
					#Input list
list1 = [2,4,7,8,3]
list2 = [4,5,0]

for value in list1:
    if value in list2:
        #Printing output
        print("True")
				
			

Output :

				
					True
				
			

Related Articles

Copy the list to another list

removing certain elements from a list

Leave a Comment