Essentially, I am trying to make a function which reads an array, and a number. If the number is within the array, it should return True, and False otherwise. However, I find that for each element in the array there is a True or False - the code checks everything individually, when I only need one True or False; is the number in the array or not ?
def is_it_there(arr, k):
for x in arr:
if x == k:
print(True)
else:
print(False)
is_it_there([8,5,2,234,426,7,11],11)
Like I said before, only one True was expected, but each item was checked and so it was False, False, False, False, False, False, True
print(k in arr)?