Skip to content

Commit e941764

Browse files
committed
Algorithms - Search - Linear Search
1 parent f8cb213 commit e941764

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
__author__ = 'Avinash'
2+
3+
lst = []
4+
num = int(input("Enter size of list: \t"))
5+
for n in range(num):
6+
numbers = int(input("Enter any number: \t"))
7+
lst.append(numbers)
8+
9+
x = int(input("\nEnter number to search: \t"))
10+
11+
found = False
12+
13+
for i in range(len(lst)):
14+
if lst[i] == x:
15+
found = True
16+
print("\n%d found at position %d" % (x, i))
17+
break
18+
if not found:
19+
print("\n%d is not in list" % x)

0 commit comments

Comments
 (0)