We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c825bb9 commit fb54d25Copy full SHA for fb54d25
1 file changed
linear_search.py
@@ -0,0 +1,11 @@
1
+nlist = [4, 2, 7, 5, 12, 54, 21, 64, 12, 32] #making a random list
2
+print('List has the items: ', nlist) #printing the items of the list
3
+searchItem = int(input('Enter a number to search for: ')) #asking for the number to be found among the shown list
4
+found = False
5
+for i in range(len(nlist)):
6
+ if nlist[i] == searchItem:
7
+ found = True
8
+ print(searchItem, ' was found in the list at index ', i)
9
+ break
10
+if found == False:
11
+ print(searchItem, ' was not found in the list!')
0 commit comments