# Python program to implement Linear Search Algorithm

Hello everyone, welcome back to programminginpython.com! Here I am going to explain to you how to implement linear search algorithm in python. This linear search is a basic search algorithm which searches all the elements in the list and finds the required value. This is also known as sequential search.

Here in this technique, I compare each and every element with the key element to be found, if both of them matches, the algorithm returns that element is found and its position.

You can also watch the video on YouTube here

#### Time Complexity

 Best Case O(1) Average Case O(n) Worst Case O(n)

#### Algorithm

Given a list `L` of `n` elements with values or records,`L0 ... Ln-1` and key/target element `K`, linear search is used to find the index/position of the target `K` in list `L`

1. Initialize a boolean variable `found` and set it to False initially
2. Start for loop with `i` ranging from 0 to the length of the list
3. Check if key element is equal to `L[i]`
1. if equals
1. set `found` boolean variable to `True`
2. print the position of the element found
3. break for loop
4. If the boolean variable `found` is equal to `False` after for loop, print that the element is not found in the list