I have two lists and want to return those sublistst of list2 that contain elements of list1. So far I tried using any: and a naive approach But I only managed to repeat empty list. The result should be Not sure, where I’m going wrong. Is there maybe a way using list comprehensions or mixing list comprehensions and ‘any’ function?
Tag: any
Python: Proper use of any() to check if one value of one array exists in another array?
In Python, I am trying to create an if statement that proceeds if one variable of one array exists somewhere in another list or array. Here is my basic code, which is supposed to check if any of the values within ids exist in follow_num: Despite my best attempts, and many versions of the above, I cannot get this to