Python Search Algorithms - Linear Search

preview_player
Показать описание


In this tutorial I teach you about the first of many searching algorithms called the 'Linear Search'. Next video will be on the 'Binary Search'
-----------------------------------------------------------------------------------------------------------
If you liked the video then please respond with a like and a subscribe to show your support for the channel and I'll repay you by creating more tutorials like this one :)
Рекомендации по теме
Комментарии
Автор

lst = [1, 100, 3, 10, -5, 7, 9]
def linser():
choice=int(input("Enter number, that you would like me to find."))
found=False
attempts=0
while (attempts < len(lst)) and (found==False):
if lst[attempts] == choice:
found = True
print("In list.")
attempts += 1
if found == False:
print("Not in list")
linser()

this does not work properly for some reason, print not found every time

DKCgame