Skip to content

Commit

Permalink
Create LinearSearch.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Neilblaze authored Oct 10, 2019
1 parent b9556a6 commit 0c723b1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Python/LinearSearch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
This is a simple Linear search algorithm for python.
This is the exact implementation of the pseudocode written in README.
"""
def linear_search(item_list,item):
index=0
while index < len(item_list):
if item_list[index] == item:
return index
index+=1
return None

#Simple demonstration of the function
if __name__=='__main__':
print (linear_search([1,3,5,7],3))
print (linear_search([1,2,5,7,97],0))

0 comments on commit 0c723b1

Please sign in to comment.