How can I print the item that is found? (without for-loop?) I want to find elements of array 1 in array 2 and then print those elements.
check = any(item in p for item in words)
print(check) # Result is TRUE
You can also use set intersection:
x = ['1', '2', '3']
y = ['2', '3', '4']
print(set(x).intersection(y))
output: {'2', '3'}
You can find more info on intersection here, note a set cannot contain any duplicates. I wasn't sure if that is a requirement.
Try
empty_lst = [print(item) for item in words if item in p]
empty_lst will store []
To store the cross-over items, do;
cross_items = [item for item in words if item in p]
The reason your question doesnt work is that item in p will always return a boolean value so item in p if item in words returns a list of True and False.
if item in p checks for the item. Look up tutorials in list comprehension to learn more.