Created
April 28, 2016 17:06
-
-
Save rahulkp220/08e9aca531a29be76521588eb8ef5972 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
#Its in python 3 | |
def LinearSearch(my_item,my_list): | |
found = False | |
position = 0 | |
while position < len(my_list) and not found: | |
if my_list[position] == my_item: | |
found = True | |
position += 1 | |
return found | |
if __name__ == '__main__': | |
my_list = ["maths","science","english","computers"] | |
my_item = input("Please enter the item to be found: ") | |
result = LinearSearch(my_item,my_list) | |
if result: | |
print("Yup, the item is in the list") | |
else: | |
print("Nope, we are sorry") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment