Last active
May 11, 2021 20:28
-
-
Save PANDATD/90d36a0e209a7d17cb836590769ebe57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def lsearch(array:list, search_element:any)->None: | |
| """ | |
| This funcation will help to search | |
| element using linear search algorithm. | |
| >>> lsearch ([134,56,2,78,0],78) | |
| Element is Found at 4th index and 5th position | |
| """ | |
| i = 0 | |
| for i in range(len(array)): | |
| if array[i] == search_element: | |
| print("Element is Found at", i,"th index and", i+1, "th position") | |
| break | |
| else: | |
| pass | |
| if i==len(array)-1: | |
| print("Element not found ") | |
| i = i+1 | |
| if __name__ == "__main__": | |
| import doctest | |
| doctest.testmod(name="lsearch",verbose=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment