Skip to content

Instantly share code, notes, and snippets.

@pycoders0000
Created December 16, 2022 04:44
Show Gist options
  • Save pycoders0000/53517f35b27c28d7e098709546eb516c to your computer and use it in GitHub Desktop.
Save pycoders0000/53517f35b27c28d7e098709546eb516c to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# @Date : 2022-07-26 07:14:08
# @Author : pycoder.py
# @GitHub : (https://github.com/pycoders0000)
# @Twitter : (https://twitter.com/pycoder0000)
# @Instagram : (https://www.instagram.com/pycoder.py/)
# @Version : 1.0.0
def search(cards, query):
position = 0
while position < len(cards):
if cards[position] == query:
return position
position += 1
return -1
search([-5, 7, 3, 2, 9, -2, -7, -1, 0], 2)
# Sequential Search algorithm is a very simple algorithm
# that is used to search for an element in a list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment