Skip to content

Commit 8fdf708

Browse files
authored
Create linearsearch.py
1 parent 452ae20 commit 8fdf708

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

python/linearsearch.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def linearsearch(arr, x):
2+
for i in range(len(arr)):
3+
if arr[i] == x:
4+
return i
5+
return -1
6+
arr = ['t','u','t','o','r','i','a','l']
7+
x = 'a'
8+
print("element found at index "+str(linearsearch(arr,x)))

0 commit comments

Comments
 (0)