Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

the most effective search method in python with example

def LinearSearch(lys, element):
    for i in range (len(lys)):
        if lys[i] == element:
            return i
    return -1

>>> print(LinearSearch([1,2,3,4,5,2,1], 2))
Source by stackabuse.com #
 
PREVIOUS NEXT
Tagged: #effective #search #method #python
ADD COMMENT
Topic
Name
9+4 =