1 parent f8cb213 commit e941764Copy full SHA for e941764
1 file changed
Algorithms/Search Algorithms/linear_search.py
@@ -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