Algorithms-and-Data-Structures/Python-Linear-Search/linearSearch.py

16 lines
301 B
Python
Raw Normal View History

2024-05-02 20:14:36 +01:00
from re import S
nums = [6, 7, 8, 12, 19, 55, 90, 98];
searchItem = 7;
found = False;
for i,j in enumerate(nums):
if j == searchItem:
print(f'found {searchItem} in nums at index {i}');
found = True;
break;
if not found:
print(f'Didn\'t find {searchItem} in nums');