Skip to content

Commit bf16d0f

Browse files
Merge pull request #10 from manvigoel/patch-1
Update Linear_Search
2 parents 51053cb + b1362dc commit bf16d0f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1+
# linear search of an item in the list inputted by the user
12

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

Comments
 (0)