1

I need some help with searching a single list for two different pieces of data, how could this be done so that if this if both pieces of data it will output the values are found.

  • 1
    Possible duplicate of [Python: Find in list](https://stackoverflow.com/questions/9542738/python-find-in-list) – YSelf Dec 01 '17 at 22:07

3 Answers3

3

You could just use a couple of in operators:

def both_in_list(lst, a, b):
    return a in lst and b in lst
Mureinik
  • 297,002
  • 52
  • 306
  • 350
2
list1 = [1,2,3,4,5,6]

list2 = [6,7,8,9,10]

if (6 in list1) and (6 in list2):

    print("The elements that you're looking for is there!")

else:

    print("One of the lists does not that the element you're looking for!")
ababuji
  • 1,683
  • 2
  • 14
  • 39
1

Used a couple in operators to do this.

    list = [2,4,8,14,16]
    if 2 in list and 4 in list
        print("2 and 4 are found in this list.")
    else:
        print("These numbers are not found in this list.")