Get your own Python server Result Size: 625 x 565
x
 
def linearSearch(arr, targetVal):
  for i in range(len(arr)):
    if arr[i] == targetVal:
      return i
  return -1
mylist = [3, 7, 2, 9, 5, 1, 8, 4, 6]
x = 4
result = linearSearch(mylist, x)
if result != -1:
  print("Found at index", result)
else:
  print("Not found")
Found at index 7