Skip to content

Instantly share code, notes, and snippets.

@rahulkp220
Created April 28, 2016 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulkp220/08e9aca531a29be76521588eb8ef5972 to your computer and use it in GitHub Desktop.
Save rahulkp220/08e9aca531a29be76521588eb8ef5972 to your computer and use it in GitHub Desktop.
#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