Posted on:

20 Jun 2023

0

LinearSearch alternate solution using For loop

my_list = [1,2,3,4,67]
item = 3

def linear_search(my_list,item):
    found = False
    for i in range(len(my_list)):
        if item == my_list[i]:
            found = True
            return found
    return found

print(linear_search(my_list, item))

0 answers ( 0 marked as helpful)

Submit an answer

  • Javascript
  • Python
  • Ruby
  • PHP
  • Java
  • C
  • C#
  • C++
  • HTML
  • SQL
  • R