0
How to have boolean results from the interaction of two lists?
That is to say:
a = [1,2,3,4,5]
b = [2,4]
for each item in a
belonging to b
return true
0
How to have boolean results from the interaction of two lists?
That is to say:
a = [1,2,3,4,5]
b = [2,4]
for each item in a
belonging to b
return true
0
You can iterate this way:
for x in a:
print(x in b)
Or so:
for x in a:
if x in b:
print(x) # ou print(x in b)
If you want to store items that are common among lists, in a new list do so:
c = set(a).intersection(set(b))
c = list(c)
Browser other questions tagged python-3.x
You are not signed in. Login or sign up in order to post.
Hello Iron Man. Thank you very much for the suggestion, which is what I will apparently have to use. I thought there would be a library or that pandas would have an easier way of doing.
– Mueladavc