Answers for "linear search in python taking input from user"

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 in python taking input from user"

Python Answers by Framework

Browse Popular Code Answers by Language