Answers for "linear search python with 3 input values into function"

5

linear search in python

def linearsearch(arr, x):
   for i in range(len(arr)):
      if arr[i] == x:
         return i
   return -1
arr = [1,2,3,4,5,6,7,8]
x = 4
print("element found at index "+str(linearsearch(arr,x)))
Posted by: Guest on June-26-2020

Code answers related to "linear search python with 3 input values into function"

Python Answers by Framework

Browse Popular Code Answers by Language