Program to implement Linear Search in Python

What is Linear Search in Python?

Linear search or sequential search is a method for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched.

Linear search runs in at worst time and makes at most n comparisons, where n is the length of the list. If each element is equally likely to be searched, then linear search has an average case of n/2 comparisons, but the average case can be affected if the search probabilities for each element vary.

Complexity: It is worst searching algorithm with worst case time complexity O(n).

 

Pseudo code with implementation:

linear search in python

 

Program to implement Linear Search in Python:

 

OUTPUT: