mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 01:00:15 +00:00
22 lines
446 B
Python
22 lines
446 B
Python
def sequentialSearch(alist, item):
|
|
pos = 0
|
|
found = False
|
|
|
|
while pos < len(alist) and not found:
|
|
|
|
if alist[pos] == item:
|
|
found = True
|
|
print("Found")
|
|
else:
|
|
pos = pos+1
|
|
if found == False:
|
|
print("Not found")
|
|
return found
|
|
|
|
print("Enter numbers seprated by space")
|
|
s = input()
|
|
numbers = list(map(int, s.split()))
|
|
trgt =int( input('enter a single number to be found in the list '))
|
|
sequentialSearch(numbers, trgt)
|
|
|