How to check element of list are present in other list?
Expand Post »
Hi,
I have two list of any datatype supported by python. I want to check whether the any of the element of first list
is present in second list or not.
Example: I have
a = [4,5,6]
b = [1,3,8,6,7,9]
I want to check whether any element of a is present in be or not. Also without using for loop.
Is there any other way to do this or any inbuilt function of python,which will check this. Please suggest me.
Re: How to check element of list are present in other list?
Hello,
Thanks for your reply.
Since I am new to python, i do not have any idea of sets. So It would be good for me if you can give me an example of, how to it convert in to sets and how to take the intersection.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.