Linear search

PHOTO EMBED

Tue Oct 31 2023 12:23:20 GMT+0000 (Coordinated Universal Time)

Saved by @bobomurod01

def linear_search(myList, x):
    for i in range(len(myList)):
        if myList[i] == x:
            return i
    return -1


myList = [1,3,4,6,7,8,10,12,23,45,56,78,99]
x = 7
print(linear_search(myList, x))
content_copyCOPY

https://www.programiz.com/python-programming/online-compiler/