Kris Armstrong Kris Armstrong - 1 year ago 71
Python Question

Python Compare value in list 1 with value in list 2

I have created two lists in python list1 and list2.

I want to start at the first element in list 1 and search for that element in list 2 if it exists print something, if it does not exist print something else

I'm not sure how to march through list 1 and search list2 for value. I know this will involve a for loop.

for in list1

if values =

Answer Source
for item in list1:
    if item in list2:
        print 'yes'
        print 'no'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download