We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 51053cb commit b1362dcCopy full SHA for b1362dc
1 file changed
SearchingAlgorithms/Linear_Search.py
@@ -1 +1,13 @@
1
+# linear search of an item in the list inputted by the user
2
3
+l = map(int, raw_input().split()) #enter space separated entries in a list
4
+item = input() #item to be searched for
5
+found = 0 #check to find if th eitem has been found or not
6
+
7
+for i in range(len(l)): #iterating through the array
8
+ if(l[i] == item): #if element found
9
+ found = 1
10
+ print('Item found in the list at index position : ' + str(i))
11
+ break
12
+if(found == 0): #if element not found
13
+ print("Sorry, Item not found in the list ")
0 commit comments